home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / c2man-2.0pl33.lha / c2man-2.0 / Configure < prev    next >
Encoding:
Text File  |  1995-01-24  |  101.9 KB  |  4,817 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them. Don't worry about any other
  4. # shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # (If you are trying to port this package to a machine without sh,
  7. # I would suggest you have a look at the prototypical config_h.SH file
  8. # and edit it to reflect your system. Some packages may include samples
  9. # of config.h for certain machines, so you might look for one of those.)
  10. #
  11. # Yes, you may rip this off to use in other distribution packages. This
  12. # script belongs to the public domain and cannot be copyrighted.
  13. #
  14. # (Note: this Configure script was generated automatically. Rather than
  15. # working with this copy of Configure, you may wish to get metaconfig.
  16. # The dist-3.0 package (which contains metaconfig) was posted in
  17. # comp.sources.misc so you may fetch it yourself from your nearest
  18. # archive site. Check with Archie if you don't know where that can be.)
  19. #
  20.  
  21. # $Id: Configure,v 2.0.1.37 1994/09/06 08:01:04 greyham Exp $
  22. #
  23. # Generated on Thu Sep  1 10:43:56 GMT+1000 1994 [metaconfig 3.0 PL35]
  24.  
  25. cat >/tmp/c1$$ <<EOF
  26. ARGGGHHHH!!!!!
  27.  
  28. SCO csh still thinks true is false.  Write to SCO today and tell them that next
  29. year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
  30.  
  31. (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
  32. we'd have to do is go in and swap the && and || tokens, wherever they are.)
  33.  
  34. [End of diatribe. We now return you to your regularly scheduled programming...]
  35. EOF
  36. cat >/tmp/c2$$ <<EOF
  37.  
  38. OOPS!  You naughty creature!  You didn't run Configure with sh!
  39. I will attempt to remedy the situation by running sh for you...
  40. EOF
  41.  
  42. true || cat /tmp/c1$$ /tmp/c2$$
  43. true || exec sh $0 $argv:q
  44.  
  45. (exit $?0) || cat /tmp/c2$$
  46. (exit $?0) || exec sh $0 $argv:q
  47. rm -f /tmp/c1$$ /tmp/c2$$
  48.  
  49. : compute my invocation name
  50. me=$0
  51. case "$0" in
  52. */*)
  53.     me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
  54.     test "$me" || me=$0
  55.     ;;
  56. esac
  57.  
  58.  
  59. : Proper PATH setting
  60. paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
  61. paths=$paths:'/usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin'
  62. paths=$paths:'/sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
  63. paths=$paths:'/bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin'
  64. paths=$paths:'/etc /usr/lib /usr/ucblib /lib /usr/ccs/lib'
  65. paths=$paths:'/sbin /usr/sbin /usr/libexec'
  66.  
  67. for p in $paths
  68. do
  69.     case ":$PATH:" in
  70.     *:$p:*) ;;
  71.     *) test -d $p && PATH=$PATH:$p ;;
  72.     esac
  73. done
  74.  
  75. PATH=.:$PATH
  76. export PATH
  77.  
  78. : Sanity checks
  79. if test ! -t 0; then
  80.     echo "Say 'sh $me', not 'sh <$me'"
  81.     exit 1
  82. fi
  83.  
  84. : On HP-UX, large Configure scripts may exercise a bug in /bin/sh
  85. if test -f /hp-ux -a -f /bin/ksh; then
  86.     if (PATH=.; alias -x) >/dev/null 2>&1; then
  87.         : already under /bin/ksh
  88.     else
  89.         cat <<'EOM'
  90. (Feeding myself to ksh to avoid nasty sh bug in "here document" expansion.)
  91. EOM
  92.         exec /bin/ksh $0 "$@"
  93.     fi
  94. else
  95.     : Warn them if they use ksh on other systems
  96.     (PATH=.; alias -x) >/dev/null 2>&1 && \
  97.         cat <<EOM
  98. (I see you are using the Korn shell.  Some ksh's blow up on $me,
  99. especially on exotic machines.  If yours does, try the Bourne shell instead.)
  100. EOM
  101. fi
  102.  
  103. : Configure runs within the UU subdirectory
  104. test -d UU || mkdir UU
  105. cd UU && rm -f *
  106.  
  107. d_bsd=''
  108. d_eunice=''
  109. d_xenix=''
  110. eunicefix=''
  111. Mcc=''
  112. awk=''
  113. bash=''
  114. bison=''
  115. byacc=''
  116. cat=''
  117. chgrp=''
  118. chmod=''
  119. chown=''
  120. compress=''
  121. cp=''
  122. cpio=''
  123. cpp=''
  124. csh=''
  125. date=''
  126. echo=''
  127. egrep=''
  128. emacs=''
  129. expr=''
  130. find=''
  131. flex=''
  132. gcc=''
  133. grep=''
  134. inews=''
  135. ksh=''
  136. less=''
  137. line=''
  138. lint=''
  139. ln=''
  140. lp=''
  141. lpr=''
  142. ls=''
  143. mail=''
  144. mailx=''
  145. make=''
  146. mkdir=''
  147. more=''
  148. mv=''
  149. nroff=''
  150. perl=''
  151. pg=''
  152. pmake=''
  153. pr=''
  154. rm=''
  155. rmail=''
  156. sed=''
  157. sendmail=''
  158. sh=''
  159. shar=''
  160. sleep=''
  161. smail=''
  162. sort=''
  163. submit=''
  164. tail=''
  165. tar=''
  166. tbl=''
  167. test=''
  168. touch=''
  169. tr=''
  170. troff=''
  171. uname=''
  172. uniq=''
  173. uuname=''
  174. vi=''
  175. zcat=''
  176. mailpatches=''
  177. notifypatches=''
  178. usermail=''
  179. hint=''
  180. myuname=''
  181. Author=''
  182. Date=''
  183. Header=''
  184. Id=''
  185. Locker=''
  186. Log=''
  187. RCSfile=''
  188. Revision=''
  189. Source=''
  190. State=''
  191. afs=''
  192. baserev=''
  193. bin=''
  194. binexp=''
  195. installbin=''
  196. cc=''
  197. gccversion=''
  198. ccflags=''
  199. cppflags=''
  200. ldflags=''
  201. lkflags=''
  202. optimize=''
  203. cf_email=''
  204. cf_by=''
  205. cf_time=''
  206. contains=''
  207. cppfilecom=''
  208. cppstdinflags=''
  209. d_cppcanstdin=''
  210. d_cppignhdrs=''
  211. cpplast=''
  212. cppminus=''
  213. cpprun=''
  214. cppstdin=''
  215. d_access=''
  216. d_const=''
  217. d_flexfnam=''
  218. d_link=''
  219. d_open3=''
  220. d_portable=''
  221. d_index=''
  222. d_strchr=''
  223. d_strftime=''
  224. d_strstr=''
  225. d_symlink=''
  226. d_time=''
  227. timetype=''
  228. d_voidsig=''
  229. signal_t=''
  230. d_volatile=''
  231. h_fcntl=''
  232. h_sysfile=''
  233. i_fcntl=''
  234. i_stddef=''
  235. i_stdlib=''
  236. i_string=''
  237. strings=''
  238. i_sysfile=''
  239. i_systypes=''
  240. i_systime=''
  241. i_systimek=''
  242. i_time=''
  243. timeincl=''
  244. i_unistd=''
  245. i_stdarg=''
  246. i_varargs=''
  247. i_varhdr=''
  248. lex=''
  249. lexflags=''
  250. libc=''
  251. liblex=''
  252. glibpth=''
  253. libpth=''
  254. plibpth=''
  255. xlibpth=''
  256. libs=''
  257. libyacc=''
  258. mailer=''
  259. installmansrc=''
  260. manext=''
  261. mansrc=''
  262. mansrcexp=''
  263. mkdep=''
  264. mydomain=''
  265. myhostname=''
  266. phostname=''
  267. c=''
  268. n=''
  269. d_berknames=''
  270. d_passnames=''
  271. d_usgnames=''
  272. nametype=''
  273. groupcat=''
  274. hostcat=''
  275. passcat=''
  276. package=''
  277. spackage=''
  278. patchlevel=''
  279. prefix=''
  280. installprivlib=''
  281. privlib=''
  282. privlibexp=''
  283. prototype=''
  284. so=''
  285. sharpbang=''
  286. shsharp=''
  287. spitshell=''
  288. startsh=''
  289. sysman=''
  290. nm_opt=''
  291. runnm=''
  292. usenm=''
  293. incpath=''
  294. mips=''
  295. mips_type=''
  296. usrinc=''
  297. vaproto=''
  298. defvoidused=''
  299. voidflags=''
  300. warnflags=''
  301. yacc=''
  302. yaccflags=''
  303. CONFIG=''
  304.  
  305. : script used to extract .SH files with variable substitutions
  306. cat >extract <<'EOS'
  307. CONFIG=true
  308. echo "Doing variable substitutions on .SH files..."
  309. if test -f MANIFEST; then
  310.     set x `awk '{print $1}' <MANIFEST | grep '\.SH'`
  311. else
  312.     echo "(Looking for .SH files under the current directory.)"
  313.     set x `find . -name "*.SH" -print`
  314. fi
  315. shift
  316. case $# in
  317. 0) set x *.SH; shift;;
  318. esac
  319. if test ! -f $1; then
  320.     shift
  321. fi
  322. for file in $*; do
  323.     case "$file" in
  324.     */*)
  325.         dir=`expr X$file : 'X\(.*\)/'`
  326.         file=`expr X$file : 'X.*/\(.*\)'`
  327.         (cd $dir && . ./$file)
  328.         ;;
  329.     *)
  330.         . ./$file
  331.         ;;
  332.     esac
  333. done
  334. if test -f config_h.SH; then
  335.     if test ! -f config.h; then
  336.     : oops, they left it out of MANIFEST, probably, so do it anyway.
  337.     . ./config_h.SH
  338.     fi
  339. fi
  340. EOS
  341.  
  342. : produce awk script to parse command line options
  343. cat >options.awk <<'EOF'
  344. BEGIN {
  345.     optstr = "deEf:hrsSD:U:V";    # getopt-style specification
  346.  
  347.     len = length(optstr);
  348.     for (i = 1; i <= len; i++) {
  349.         c = substr(optstr, i, 1);
  350.         if (i < len) a = substr(optstr, i + 1, 1); else a = "";
  351.         if (a == ":") {
  352.             arg[c] = 1;
  353.             i++;
  354.         }
  355.         opt[c] = 1;
  356.     }
  357. }
  358. {
  359.     expect = 0;
  360.     str = $0;
  361.     if (substr(str, 1, 1) != "-") {
  362.         printf("'%s'\n", str);
  363.         next;
  364.     }
  365.     len = length($0);
  366.     for (i = 2; i <= len; i++) {
  367.         c = substr(str, i, 1);
  368.         if (!opt[c]) {
  369.             printf("-%s\n", substr(str, i));
  370.             next;
  371.         }
  372.         printf("-%s\n", c);
  373.         if (arg[c]) {
  374.             if (i < len)
  375.                 printf("'%s'\n", substr(str, i + 1));
  376.             else
  377.                 expect = 1;
  378.             next;
  379.         }
  380.     }
  381. }
  382. END {
  383.     if (expect)
  384.         print "?";
  385. }
  386. EOF
  387.  
  388. : process the command line options
  389. set X `for arg in "$@"; do echo $arg; done | awk -f options.awk`
  390. eval "set $*"
  391. shift
  392. rm -f options.awk
  393.  
  394. : set up default values
  395. fastread=''
  396. reuseval=false
  397. config_sh=''
  398. alldone=''
  399. error=''
  400. silent=''
  401. extractsh=''
  402. optdef='optdef.sh'
  403.  
  404. : option parsing
  405. while test $# -gt 0; do
  406.     case "$1" in
  407.     -d) shift; fastread=yes;;
  408.     -e) shift; alldone=cont;;
  409.     -f)
  410.         shift
  411.         cd ..
  412.         if test -r "$1"; then
  413.             config_sh="$1"
  414.         else
  415.             echo "$me: cannot read config file $1." >&2
  416.             error=true
  417.         fi
  418.         cd UU
  419.         shift;;
  420.     -h) shift; error=true;;
  421.     -r) shift; reuseval=true;;
  422.     -s) shift; silent=true;;
  423.     -E) shift; alldone=exit;;
  424.     -S) shift; extractsh=true;;
  425.     -D)
  426.         shift
  427.         case "$1" in
  428.         *=)
  429.             echo "$me: use '-U symbol=', not '-D symbol='." >&2
  430.             echo "$me: ignoring -D $1" >&2
  431.             ;;
  432.         *=*) echo "$1" >> $optdef;;
  433.         *) echo "$1='define'" >> $optdef;;
  434.         esac
  435.         shift
  436.         ;;
  437.     -U)
  438.         shift
  439.         case "$1" in
  440.         *=) echo "$1" >> $optdef;;
  441.         *=*)
  442.             echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
  443.             echo "$me: ignoring -U $1" >&2
  444.             ;;
  445.         *) echo "$1='undef'" >> $optdef;;
  446.         esac
  447.         shift
  448.         ;;
  449.     -V) echo "$me generated by metaconfig 3.0 PL35." >&2
  450.         exit 0;;
  451.     --) break;;
  452.     -*) echo "$me: unknown option $1" >&2; shift; error=true;;
  453.     *) break;;
  454.     esac
  455. done
  456.  
  457. case "$error" in
  458. true)
  459.     cat >&2 <<EOM
  460. Usage: $me [-dehrESV] [-f config.sh] [-D symbol] [-D symbol=value]
  461.                  [-U symbol] [-U symbol=]
  462.   -d : use defaults for all answers.
  463.   -e : go on without questioning past the production of config.sh.
  464.   -f : specify an alternate default configuration file.
  465.   -h : print this help message and exit (with an error status).
  466.   -r : reuse C symbols value if possible (skips costly nm extraction).
  467.   -s : silent mode, only echoes questions and essential information.
  468.   -D : define symbol to have some value:
  469.          -D symbol         symbol gets the value 'define'
  470.          -D symbol=value   symbol gets the value 'value'
  471.   -E : stop at the end of questions, after having produced config.sh.
  472.   -S : perform variable substitutions on all .SH files (can mix with -f)
  473.   -U : undefine symbol:
  474.          -U symbol    symbol gets the value 'undef'
  475.          -U symbol=   symbol gets completely empty
  476.   -V : print version number and exit (with a zero status).
  477. EOM
  478.     exit 1
  479.     ;;
  480. esac
  481.  
  482. exec 4>&1
  483. case "$silent" in
  484. true) exec 1>/dev/null;;
  485. esac
  486.  
  487. : run the defines and the undefines, if any
  488. touch $optdef
  489. . ./$optdef
  490. rm -f $optdef
  491.  
  492. case "$extractsh" in
  493. true)
  494.     case "$config_sh" in
  495.     '') config_sh='config.sh'; config='./config.sh';;
  496.     /*) config="$config_sh";;
  497.     *) config="./$config_sh";;
  498.     esac
  499.     echo " "
  500.     echo "Fetching answers from $config_sh..."
  501.     cd ..
  502.     . $config
  503.     echo " "
  504.     . ./UU/extract
  505.     rm -rf UU
  506.     echo "Done."
  507.     exit 0
  508.     ;;
  509. esac
  510.  
  511. : set package name
  512. package=c2man
  513.  
  514. : Eunice requires " " instead of "", can you believe it
  515. echo " "
  516. : Here we go...
  517. echo "Beginning of configuration questions for $package."
  518.  
  519. define='define'
  520. undef='undef'
  521. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  522. rmlist=''
  523.  
  524. trap 'echo " "; rm -rf $rmlist; exit 1' 1 2 3 15
  525.  
  526. : We must find out about Eunice early
  527. eunicefix=':'
  528. if test -f /etc/unixtovms; then
  529.     eunicefix=/etc/unixtovms
  530. fi
  531. if test -f /etc/unixtovms.exe; then
  532.     eunicefix=/etc/unixtovms.exe
  533. fi
  534.  
  535. gccversion='1'
  536. : no include file wanted by default
  537. inclwanted=''
  538.  
  539. i_sysselct=''
  540. : change the next line if compiling for Xenix/286 on Xenix/386
  541. xlibpth='/usr/lib/386 /lib/386'
  542.  
  543. : general looking path for locating libraries
  544. glibpth="/lib/pa1.1 /usr/lib/large /lib /usr/lib $xlibpth"
  545. glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
  546. glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib /usr/shlib"
  547.  
  548. : Private path used by Configure to find libraries.  Its value
  549. : is prepended to libpth. This variable takes care of special
  550. : machines, like the mips.  Usually, it should be empty.
  551. plibpth=''
  552.  
  553. : default library list
  554. libswanted=''
  555. large=''
  556. : full support for void wanted by default
  557. defvoidused=15
  558.  
  559. defvoidused=9
  560.  
  561. : remove obsolete files from old patchlevels and their derivatives.
  562. rm -f ../fixpre.in ../fixpre.sed ../fixpost.in ../fixpost.sed
  563. rm -f ../flatten_sed.SH ../fixexample.in ../fixexample.sed
  564. rm -f ../eg/commentafter.c ../eg/multipledecl.c
  565.  
  566. : 2.0pl28 moved some files around - do it without the big patch baggage.
  567. mv -f ../pc/COPYING ../pc/getopt.[ch] ../pc/getopt1.c ../libc 2>/dev/null
  568.  
  569. : 2.0pl31 changed the way the manual was organised
  570. test -f ../c2man.man || mv -f ../c2man.1 ../c2man.man
  571.  
  572. : Some greps do not return status, grrr.
  573. echo "grimblepritz" >grimble
  574. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  575.     contains=contains
  576. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  577.     contains=grep
  578. else
  579.     contains=contains
  580. fi
  581. rm -f grimble
  582. : the following should work in any shell
  583. case "$contains" in
  584. contains*)
  585.     echo " "
  586.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  587.     cat >contains <<'EOSS'
  588. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  589. EOSS
  590. chmod +x contains
  591. esac
  592.  
  593. : first determine how to suppress newline on echo command
  594. echo " "
  595. echo "Checking echo to see how to suppress newlines..."
  596. (echo "hi there\c" ; echo " ") >.echotmp
  597. if $contains c .echotmp >/dev/null 2>&1 ; then
  598.     echo "...using -n."
  599.     n='-n'
  600.     c=''
  601. else
  602.     cat <<'EOM'
  603. ...using \c
  604. EOM
  605.     n=''
  606.     c='\c'
  607. fi
  608. echo $n "The star should be here-->$c"
  609. echo '*'
  610. rm -f .echotmp
  611.  
  612. : Now test for existence of everything in MANIFEST
  613. echo " "
  614. if test -f ../MANIFEST; then
  615.     echo "First let's make sure your kit is complete.  Checking..." >&4
  616.     awk '$1 !~ /PACK[A-Z]+/ {print $1}' ../MANIFEST | split -50
  617.     rm -f missing
  618.     for filelist in x??; do
  619.         (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing)
  620.     done
  621.     if test -s missing; then
  622.         cat missing >&4
  623.         cat >&4 <<'EOM'
  624.  
  625. THIS PACKAGE SEEMS TO BE INCOMPLETE.
  626.  
  627. You have the option of continuing the configuration process, despite the
  628. distinct possibility that your kit is damaged, by typing 'y'es.  If you
  629. do, don't blame me if something goes wrong.  I advise you to type 'n'o
  630. and contact the author (greyham@research.canon.oz.au).
  631.  
  632. EOM
  633.         echo $n "Continue? [n] $c" >&4
  634.         read ans
  635.         case "$ans" in
  636.         y*)
  637.             echo "Continuing..." >&4
  638.             rm -f missing
  639.             ;;
  640.         *)
  641.             echo "ABORTING..." >&4
  642.             kill $$
  643.             ;;
  644.         esac
  645.     else
  646.         echo "Looks good..." >&4
  647.     fi
  648. else
  649.     echo "There is no MANIFEST file.  I hope your kit is complete !"
  650. fi
  651. rm -f missing x??
  652.  
  653. : compute the number of columns on the terminal for proper question formatting
  654. case "$COLUMNS" in
  655. '') COLUMNS='80';;
  656. esac
  657.  
  658. : set up the echo used in my read
  659. myecho="case \"\$xxxm\" in
  660. '') echo $n \"\$rp $c\" >&4;;
  661. *) case \"\$rp\" in
  662.     '') echo $n \"[\$xxxm] $c\";;
  663.     *)
  664.         if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
  665.             echo \"\$rp\" >&4
  666.             echo $n \"[\$xxxm] $c\" >&4
  667.         else
  668.             echo $n \"\$rp [\$xxxm] $c\" >&4
  669.         fi
  670.         ;;
  671.     esac;;
  672. esac"
  673.  
  674. : now set up to do reads with possible shell escape and default assignment
  675. cat <<EOSC >myread
  676. xxxm=\$dflt
  677. $myecho
  678. ans='!'
  679. case "\$fastread" in
  680. yes) case "\$dflt" in
  681.     '') ;;
  682.     *) ans='';
  683.         case "\$silent-\$rp" in
  684.         true-) ;;
  685.         *) echo " " >&4;;
  686.         esac;;
  687.     esac;;
  688. *) case "\$silent" in
  689.     true) case "\$rp" in
  690.         '') ans='';;
  691.         esac;;
  692.     esac;;
  693. esac
  694. while expr "X\$ans" : "X!" >/dev/null; do
  695.     read answ
  696.     set x \$xxxm
  697.     shift
  698.     aok=''; eval "ans=\"\$answ\"" && aok=y
  699.     case  "\$answ" in
  700.     "\$ans")
  701.         case "\$ans" in
  702.         "!")
  703.             sh 1>&4
  704.             echo " "
  705.             $myecho
  706.             ;;
  707.         !*)
  708.             set x \`expr "X\$ans" : "X!\(.*\)\$"\`
  709.             shift
  710.             sh 1>&4 -c "\$*"
  711.             echo " "
  712.             $myecho
  713.             ;;
  714.         esac;;
  715.     *)
  716.         case "\$aok" in
  717.         y)
  718.             echo "*** Substitution done -- please confirm."
  719.             xxxm="\$ans"
  720.             ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
  721.             xxxm="\$ans"
  722.             ans=!
  723.             ;;
  724.         *)
  725.             echo "*** Error -- try again."
  726.             ans=!
  727.             ;;
  728.         esac
  729.         $myecho
  730.         ;;
  731.     esac
  732.     case "\$ans\$xxxm\$nostick" in
  733.     '')
  734.         ans=!
  735.         $myecho
  736.         ;;
  737.     esac
  738. done
  739. case "\$ans" in
  740. '') ans="\$xxxm";;
  741. esac
  742. EOSC
  743.  
  744. : create .config dir to save info across Configure sessions
  745. test -d ../.config || mkdir ../.config
  746. cat >../.config/README <<EOF
  747. This directory created by Configure to save information that should
  748. persist across sessions.
  749.  
  750. You may safely delete it if you wish.
  751. EOF
  752.  
  753. : general instructions
  754. needman=true
  755. firsttime=true
  756. user=`( (logname) 2>/dev/null || whoami) 2>&1`
  757. if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
  758.     firsttime=false
  759.     echo " "
  760.     rp='Would you like to see the instructions?'
  761.     dflt=n
  762.     . ./myread
  763.     case "$ans" in
  764.     [yY]*) ;;
  765.     *) needman=false;;
  766.     esac
  767. fi
  768. if $needman; then
  769.     cat <<EOH
  770.  
  771. This installation shell script will examine your system and ask you questions
  772. to determine how the c2man package should be installed. If you get
  773. stuck on a question, you may use a ! shell escape to start a subshell or
  774. execute a command.  Many of the questions will have default answers in square
  775. brackets; typing carriage return will give you the default.
  776.  
  777. On some of the questions which ask for file or directory names you are allowed
  778. to use the ~name construct to specify the login directory belonging to "name",
  779. even if you don't have a shell which knows about that.  Questions where this is
  780. allowed will be marked "(~name ok)".
  781.  
  782. EOH
  783.     rp=''
  784.     dflt='Type carriage return to continue'
  785.     . ./myread
  786.     cat <<'EOH'
  787.  
  788. The prompter used in this script allows you to use shell variables and
  789. backticks in your answers.  You may use $1, $2, etc...  to refer to the words
  790. in the default answer, as if the default line was a set of arguments given to a
  791. script shell.  This means you may also use $* to repeat the whole default line,
  792. so you do not have to re-type everything to add something to the default.
  793.  
  794. Everytime there is a substitution, you will have to confirm.  If there is an
  795. error (e.g. an unmatched backtick), the default answer will remain unchanged
  796. and you will be prompted again.
  797.  
  798. If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
  799. the questions and use the computed defaults (or the previous answers if there
  800. was already a config.sh file). Type 'Configure -h' for a list of options.
  801.  
  802. EOH
  803.     . ./myread
  804.     cat <<EOH
  805.  
  806. Much effort has been expended to ensure that this shell script will run on any
  807. Unix system.  If despite that it blows up on yours, your best bet is to edit
  808. Configure and run it again.  Also, let me (greyham@research.canon.oz.au)
  809. know how I blew it.  If you can't run Configure for some reason, you'll have to
  810. generate a config.sh file by hand.
  811.  
  812. This installation script affects things in two ways:
  813.  
  814. 1) it may do direct variable substitutions on some of the files included
  815.    in this kit.
  816. 2) it builds a config.h file for inclusion in C programs.  You may edit
  817.    any of these files as the need arises after running this script.
  818.  
  819. If you make a mistake on a question, there is no easy way to back up to it
  820. currently.  The easiest thing to do is to edit config.sh and rerun all the SH
  821. files.  Configure will offer to let you do this before it runs the SH files.
  822.  
  823. EOH
  824.     dflt='Type carriage return to continue'
  825.     . ./myread
  826.     case "$firsttime" in
  827.     true) echo $user >>../.config/instruct;;
  828.     esac
  829. fi
  830.  
  831. : see if sh knows # comments
  832. echo " "
  833. echo "Checking your sh to see if it knows about # comments..." >&4
  834. if sh -c '#' >/dev/null 2>&1 ; then
  835.     echo "Your sh handles # comments correctly."
  836.     shsharp=true
  837.     spitshell=cat
  838.     echo " "
  839.     echo "Okay, let's see if #! works on this system..."
  840.     xcat=/bin/cat
  841.     test -r $xcat || xcat=/usr/bin/cat
  842.     echo "#!$xcat" >try
  843.     $eunicefix try
  844.     chmod +x try
  845.     ./try > today
  846.     if test -s today; then
  847.         echo "It does."
  848.         sharpbang='#!'
  849.     else
  850.         echo "#! $xcat" > try
  851.         $eunicefix try
  852.         chmod +x try
  853.         ./try > today
  854.         if test -s today; then
  855.             echo "It does."
  856.             sharpbang='#! '
  857.         else
  858.             echo "It's just a comment."
  859.             sharpbang=': use '
  860.         fi
  861.     fi
  862. else
  863.     echo "Your sh doesn't grok # comments--I will strip them later on."
  864.     shsharp=false
  865.     cd ..
  866.     echo "exec grep -v '^[     ]*#'" >spitshell
  867.     chmod +x spitshell
  868.     $eunicefix spitshell
  869.     spitshell=`pwd`/spitshell
  870.     cd UU
  871.     echo "I presume that if # doesn't work, #! won't work either!"
  872.     sharpbang=': use '
  873. fi
  874. rm -f try today
  875.  
  876. : figure out how to guarantee sh startup
  877. echo " "
  878. echo "Checking out how to guarantee sh startup..." >&4
  879. case "$SYSTYPE" in
  880. *bsd*|sys5*) startsh=$sharpbang"/$SYSTYPE/bin/sh";;
  881. *) startsh=$sharpbang'/bin/sh';;
  882. esac
  883. echo "Let's see if '$startsh' works..."
  884. cat >try <<EOSS
  885. $startsh
  886. set abc
  887. test "$?abc" != 1
  888. EOSS
  889.  
  890. chmod +x try
  891. $eunicefix try
  892. if ./try; then
  893.     echo "Yup, it does."
  894. else
  895. echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  896. fi
  897. rm -f try
  898.  
  899. : find out where common programs are
  900. echo " "
  901. echo "Locating common programs..." >&4
  902. cat <<EOSC >loc
  903. $startsh
  904. case \$# in
  905. 0) exit 1;;
  906. esac
  907. thing=\$1
  908. shift
  909. dflt=\$1
  910. shift
  911. for dir in \$*; do
  912.     case "\$thing" in
  913.     .)
  914.     if test -d \$dir/\$thing; then
  915.         echo \$dir
  916.         exit 0
  917.     fi
  918.     ;;
  919.     *)
  920.     if test -f \$dir/\$thing; then
  921.         echo \$dir/\$thing
  922.         exit 0
  923.     elif test -f \$dir/\$thing.exe; then
  924.         : on Eunice apparently
  925.         echo \$dir/\$thing
  926.         exit 0
  927.     fi
  928.     ;;
  929.     esac
  930. done
  931. echo \$dflt
  932. exit 1
  933. EOSC
  934. chmod +x loc
  935. $eunicefix loc
  936. loclist="
  937. awk
  938. cat
  939. cp
  940. echo
  941. expr
  942. grep
  943. mv
  944. rm
  945. sed
  946. sort
  947. tr
  948. uniq
  949. "
  950. trylist="
  951. Mcc
  952. bison
  953. byacc
  954. cpp
  955. date
  956. flex
  957. mail
  958. nroff
  959. rmail
  960. sendmail
  961. smail
  962. test
  963. uname
  964. "
  965. pth=`echo $PATH | sed -e 's/:/ /g'`
  966. pth="$pth /lib /usr/lib"
  967. for file in $loclist; do
  968.     xxx=`./loc $file $file $pth`
  969.     eval $file=$xxx
  970.     eval _$file=$xxx
  971.     case "$xxx" in
  972.     /*)
  973.         echo $file is in $xxx.
  974.         ;;
  975.     *)
  976.         echo "I don't know where $file is.  I hope it's in everyone's PATH."
  977.         ;;
  978.     esac
  979. done
  980. echo " "
  981. echo "Don't worry if any of the following aren't found..."
  982. say=offhand
  983. for file in $trylist; do
  984.     xxx=`./loc $file $file $pth`
  985.     eval $file=$xxx
  986.     eval _$file=$xxx
  987.     case "$xxx" in
  988.     /*)
  989.         echo $file is in $xxx.
  990.         ;;
  991.     *)
  992.         echo "I don't see $file out there, $say."
  993.         say=either
  994.         ;;
  995.     esac
  996. done
  997. case "$egrep" in
  998. egrep)
  999.     echo "Substituting grep for egrep."
  1000.     egrep=$grep
  1001.     ;;
  1002. esac
  1003. case "$test" in
  1004. test)
  1005.     echo "Hopefully test is built into your sh."
  1006.     ;;
  1007. *)
  1008.     if sh -c "PATH= test true" >/dev/null 2>&1; then
  1009.         echo "Using the test built into your sh."
  1010.         test=test
  1011.         _test=test
  1012.     fi
  1013.     ;;
  1014. esac
  1015. case "$echo" in
  1016. echo)
  1017.     echo "Hopefully echo is built into your sh."
  1018.     ;;
  1019. '') ;;
  1020. *)
  1021.     echo " "
  1022. echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
  1023.     $echo $n "hi there$c" >foo1
  1024.     echo $n "hi there$c" >foo2
  1025.     if cmp foo1 foo2 >/dev/null 2>&1; then
  1026.         echo "They are compatible.  In fact, they may be identical."
  1027.     else
  1028.         case "$n" in
  1029.         '-n') n='' c='\c';;
  1030.         *) n='-n' c='';;
  1031.         esac
  1032.         cat <<FOO
  1033. They are not compatible!  You are probably running ksh on a non-USG system.
  1034. I'll have to use $echo instead of the builtin, since Bourne shell doesn't
  1035. have echo built in and we may have to run some Bourne shell scripts.  That
  1036. means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
  1037.  
  1038. FOO
  1039.         $echo $n "The star should be here-->$c"
  1040.         $echo "*"
  1041.     fi
  1042.     $rm -f foo1 foo2
  1043.     ;;
  1044. esac
  1045.  
  1046. : Try to determine whether config.sh was made on this system
  1047. case "$config_sh" in
  1048. '')
  1049. myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
  1050. myuname=`echo $myuname | $sed -e 's/^[^=]*=//' | \
  1051.     tr '[A-Z]' '[a-z]' | tr '\012' ' '`
  1052. dflt=n
  1053. if test -f ../config.sh; then
  1054.     oldmyuname=''
  1055.     if $contains myuname= ../config.sh >/dev/null 2>&1; then
  1056.         eval "old`grep myuname= ../config.sh`"
  1057.     fi
  1058.     if test "X$myuname" = "X$oldmyuname"; then
  1059.         dflt=y
  1060.     fi
  1061. fi
  1062.  
  1063. : Get old answers, if there is a config file out there
  1064. hint=default
  1065. if test -f ../config.sh; then
  1066.     echo " "
  1067.     rp="I see a config.sh file.  Shall I use it to set the defaults?"
  1068.     . ./myread
  1069.     case "$ans" in
  1070.     n*|N*) echo "OK, I'll ignore it.";;
  1071.     *)  echo "Fetching default answers from your old config.sh file..." >&4
  1072.         tmp="$n"
  1073.         tans="$c"
  1074.         . ../config.sh
  1075.         cp ../config.sh .
  1076.         n="$tmp"
  1077.         c="$tans"
  1078.         hint=previous
  1079.         ;;
  1080.     esac
  1081. fi
  1082. ;;
  1083. *)
  1084.     echo " "
  1085.     echo "Fetching default answers from $config_sh..." >&4
  1086.     tmp="$n"
  1087.     tans="$c"
  1088.     cd ..
  1089.     cp $config_sh config.sh 2>/dev/null
  1090.     . ./config.sh
  1091.     cd UU
  1092.     cp ../config.sh .
  1093.     n="$tmp"
  1094.     c="$tans"
  1095.     hint=previous
  1096.     ;;
  1097. esac
  1098.  
  1099. : Restore computed paths
  1100. for file in $loclist $trylist; do
  1101.     eval $file="\$_$file"
  1102. done
  1103.  
  1104. : who configured the system
  1105. cf_time=`$date 2>&1`
  1106. (logname > .temp) >/dev/null 2>&1
  1107. $test -s .temp || (whoami > .temp) >/dev/null 2>&1
  1108. $test -s .temp || echo unknown > .temp
  1109. cf_by=`$cat .temp`
  1110. $rm -f .temp
  1111.  
  1112. : determine where manual pages are on this system
  1113. echo " "
  1114. case "$sysman" in
  1115. '') 
  1116.     syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
  1117.     syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
  1118.     syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
  1119.     syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  1120.     syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
  1121.     sysman=`./loc . /usr/man/man1 $syspath`
  1122.     ;;
  1123. esac
  1124. if $test -d "$sysman"; then
  1125.     echo "System manual is in $sysman." >&4
  1126. else
  1127.     echo "Could not find manual pages in source form." >&4
  1128. fi
  1129.  
  1130. : make some quick guesses about what we are up against
  1131. echo " "
  1132. $echo $n "Hmm...  $c"
  1133. echo exit 1 >bsd
  1134. echo exit 1 >usg
  1135. echo exit 1 >v7
  1136. echo exit 1 >osf1
  1137. echo exit 1 >eunice
  1138. echo exit 1 >xenix
  1139. echo exit 1 >venix
  1140. d_bsd="$undef"
  1141. $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
  1142. if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
  1143. then
  1144.     echo "Looks kind of like an OSF/1 system, but we'll see..."
  1145.     echo exit 0 >osf1
  1146. elif test `echo abc | tr a-z A-Z` = Abc ; then
  1147.     xxx=`./loc addbib blurfl $pth`
  1148.     if $test -f $xxx; then
  1149.     echo "Looks kind of like a USG system with BSD features, but we'll see..."
  1150.         echo exit 0 >bsd
  1151.         echo exit 0 >usg
  1152.     else
  1153.         if $contains SIGTSTP foo >/dev/null 2>&1 ; then
  1154.             echo "Looks kind of like an extended USG system, but we'll see..."
  1155.         else
  1156.             echo "Looks kind of like a USG system, but we'll see..."
  1157.         fi
  1158.         echo exit 0 >usg
  1159.     fi
  1160. elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  1161.     echo "Looks kind of like a BSD system, but we'll see..."
  1162.     d_bsd="$define"
  1163.     echo exit 0 >bsd
  1164. else
  1165.     echo "Looks kind of like a Version 7 system, but we'll see..."
  1166.     echo exit 0 >v7
  1167. fi
  1168. case "$eunicefix" in
  1169. *unixtovms*)
  1170.     $cat <<'EOI'
  1171. There is, however, a strange, musty smell in the air that reminds me of
  1172. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  1173. EOI
  1174.     echo exit 0 >eunice
  1175.     d_eunice="$define"
  1176. : it so happens the Eunice I know will not run shell scripts in Unix format
  1177.     ;;
  1178. *)
  1179.     echo " "
  1180.     echo "Congratulations.  You aren't running Eunice."
  1181.     d_eunice="$undef"
  1182.     ;;
  1183. esac
  1184. if test -f /xenix; then
  1185.     echo "Actually, this looks more like a XENIX system..."
  1186.     echo exit 0 >xenix
  1187.     d_xenix="$define"
  1188. else
  1189.     echo " "
  1190.     echo "It's not Xenix..."
  1191.     d_xenix="$undef"
  1192. fi
  1193. chmod +x xenix
  1194. $eunicefix xenix
  1195. if test -f /venix; then
  1196.     echo "Actually, this looks more like a VENIX system..."
  1197.     echo exit 0 >venix
  1198. else
  1199.     echo " "
  1200.     if xenix; then
  1201.         : null
  1202.     else
  1203.         echo "Nor is it Venix..."
  1204.     fi
  1205. fi
  1206. chmod +x bsd usg v7 osf1 eunice xenix venix
  1207. $eunicefix bsd usg v7 osf1 eunice xenix venix
  1208. $rm -f foo
  1209.  
  1210. : see if we need a special compiler
  1211. echo " "
  1212. if usg; then
  1213.     case "$cc" in
  1214.     '') case "$Mcc" in
  1215.         /*) dflt='Mcc';;
  1216.         *) case "$large" in
  1217.             -M*) dflt='cc';;
  1218.             *)    if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
  1219.                     if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
  1220.                         dflt='cc'
  1221.                     else
  1222.                         dflt='cc -M'
  1223.                     fi
  1224.                 else
  1225.                     dflt='cc'
  1226.                 fi;;
  1227.             esac;;
  1228.         esac;;
  1229.     *)  dflt="$cc";;
  1230.     esac
  1231.     $cat <<'EOM'
  1232. On some systems the default C compiler will not resolve multiple global
  1233. references that happen to have the same name.  On some such systems the "Mcc"
  1234. command may be used to force these to be resolved.  On other systems a "cc -M"
  1235. command is required.  (Note that the -M flag on other systems indicates a
  1236. memory model to use!) If you have the Gnu C compiler, you might wish to use
  1237. that instead.
  1238.  
  1239. EOM
  1240.     rp="What command will force resolution on this system?"
  1241.     . ./myread
  1242.     cc="$ans"
  1243. else
  1244.     case "$cc" in
  1245.     '') dflt=cc;;
  1246.     *) dflt="$cc";;
  1247.     esac
  1248.     rp="Use which C compiler?"
  1249.     . ./myread
  1250.     cc="$ans"
  1251. fi
  1252. case "$cc" in
  1253. gcc*)
  1254.     echo "Checking out which version of gcc you have..." >&4
  1255.     $cat >gccvers.c <<EOM
  1256. #include <stdio.h>
  1257. int main()
  1258. {
  1259.     char *v;
  1260.     v = "unknown";
  1261. #ifdef __GNUC__
  1262. #ifdef __VERSION__
  1263.     v = __VERSION__;
  1264. #endif
  1265. #endif
  1266.     switch((int) v[0]) {
  1267.         case '1': printf("1\n"); break;
  1268.         case '2': printf("2\n"); break;
  1269.         case '3': printf("3\n"); break;
  1270.         default: break;
  1271.     }
  1272. #ifdef __GNUC__
  1273.     return 0;
  1274. #else
  1275.     return 1;
  1276. #endif
  1277. }
  1278. EOM
  1279.     if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
  1280.         gccversion=`./gccvers`
  1281.         echo "You appear to have version $gccversion."
  1282.     else
  1283.         echo "Doesn't appear to be GNU cc after all."
  1284.     fi
  1285.     $rm -f gccvers*
  1286.     if $test "$gccversion" = '1'; then
  1287.         cpp=`./loc gcc-cpp $cpp $pth`
  1288.     fi
  1289.     ;;
  1290. esac
  1291.  
  1292. : decide how portable to be
  1293. case "$d_portable" in
  1294. "$define") dflt=y;;
  1295. *)    dflt=n;;
  1296. esac
  1297. $cat <<'EOH'
  1298.  
  1299. I can set things up so that your shell scripts and binaries are more portable,
  1300. at what may be a noticable cost in performance.  In particular, if you
  1301. ask to be portable, the following happens:
  1302.  
  1303.      1) Shell scripts will rely on the PATH variable rather than using
  1304.     the paths derived above.
  1305.      2) ~username interpretations will be done at run time rather than
  1306.     by Configure.
  1307.  
  1308. EOH
  1309. rp="Do you expect to run these scripts and binaries on multiple machines?"
  1310. . ./myread
  1311. case "$ans" in
  1312.     y*) d_portable="$define"
  1313.     for file in $loclist $trylist; do
  1314.         eval $file="\$file"
  1315.     done
  1316.     ;;
  1317.     *)  d_portable="$undef" ;;
  1318. esac
  1319.  
  1320. : set up shell script to do ~ expansion
  1321. cat >filexp <<EOSS
  1322. $startsh
  1323. : expand filename
  1324. case "\$1" in
  1325.  ~/*|~)
  1326.     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  1327.     ;;
  1328.  ~*)
  1329.     if $test -f /bin/csh; then
  1330.         /bin/csh -f -c "glob \$1"
  1331.         failed=\$?
  1332.         echo ""
  1333.         exit \$failed
  1334.     else
  1335.         name=\`$expr x\$1 : '..\([^/]*\)'\`
  1336.         dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  1337.         if $test ! -d "\$dir"; then
  1338.             me=\`basename \$0\`
  1339.             echo "\$me: can't locate home directory for: \$name" >&2
  1340.             exit 1
  1341.         fi
  1342.         case "\$1" in
  1343.         */*)
  1344.             echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  1345.             ;;
  1346.         *)
  1347.             echo \$dir
  1348.             ;;
  1349.         esac
  1350.     fi
  1351.     ;;
  1352. *)
  1353.     echo \$1
  1354.     ;;
  1355. esac
  1356. EOSS
  1357. chmod +x filexp
  1358. $eunicefix filexp
  1359.  
  1360. : now set up to get a file name
  1361. cat <<'EOSC' >getfile
  1362. tilde=''
  1363. fullpath=''
  1364. already=''
  1365. skip=''
  1366. none_ok=''
  1367. exp_file=''
  1368. nopath_ok=''
  1369. orig_rp="$rp"
  1370. orig_dflt="$dflt"
  1371.  
  1372. case "$fn" in
  1373. *:*)
  1374.     loc_file=`expr $fn : '.*:\(.*\)'`
  1375.     fn=`expr $fn : '\(.*\):.*'`
  1376.     ;;
  1377. esac
  1378.  
  1379. case "$fn" in
  1380. *~*) tilde=true;;
  1381. esac
  1382. case "$fn" in
  1383. */*) fullpath=true;;
  1384. esac
  1385. case "$fn" in
  1386. *+*) skip=true;;
  1387. esac
  1388. case "$fn" in
  1389. *n*) none_ok=true;;
  1390. esac
  1391. case "$fn" in
  1392. *e*) exp_file=true;;
  1393. esac
  1394. case "$fn" in
  1395. *p*) nopath_ok=true;;
  1396. esac
  1397.  
  1398. case "$fn" in
  1399. *f*) type='File';;
  1400. *d*) type='Directory';;
  1401. *l*) type='Locate';;
  1402. esac
  1403.  
  1404. what="$type"
  1405. case "$what" in
  1406. Locate) what='File';;
  1407. esac
  1408.  
  1409. case "$exp_file" in
  1410. '')
  1411.     case "$d_portable" in
  1412.     "$define") ;;
  1413.     *) exp_file=true;;
  1414.     esac
  1415.     ;;
  1416. esac
  1417.  
  1418. cd ..
  1419. while test "$type"; do
  1420.     redo=''
  1421.     rp="$orig_rp"
  1422.     dflt="$orig_dflt"
  1423.     case "$tilde" in
  1424.     true) rp="$rp (~name ok)";;
  1425.     esac
  1426.     . UU/myread
  1427.     case "$ans" in
  1428.     none)
  1429.         value=''
  1430.         ansexp=''
  1431.         case "$none_ok" in
  1432.         true) type='';;
  1433.         esac
  1434.         ;;
  1435.     *)
  1436.         case "$tilde" in
  1437.         '') value="$ans"
  1438.             ansexp="$ans";;
  1439.         *)
  1440.             value=`UU/filexp $ans`
  1441.             case $? in
  1442.             0)
  1443.                 if test "$ans" != "$value"; then
  1444.                     echo "(That is $value on this particular system.)"
  1445.                 fi
  1446.                 ;;
  1447.             *) value="$ans";;
  1448.             esac
  1449.             ansexp="$value"
  1450.             case "$exp_file" in
  1451.             '') value="$ans";;
  1452.             esac
  1453.             ;;
  1454.         esac
  1455.         case "$fullpath" in
  1456.         true)
  1457.             case "$ansexp" in
  1458.             /*) value="$ansexp" ;;
  1459.             *)
  1460.                 redo=true
  1461.                 case "$already" in
  1462.                 true)
  1463.                 echo "I shall only accept a full path name, as in /bin/ls." >&4
  1464.                 echo "Use a ! shell escape if you wish to check pathnames." >&4
  1465.                     ;;
  1466.                 *)
  1467.                 echo "Please give a full path name, starting with slash." >&4
  1468.                     case "$tilde" in
  1469.                     true)
  1470.                 echo "Note that using ~name is ok provided it expands well." >&4
  1471.                         already=true
  1472.                         ;;
  1473.                     esac
  1474.                 esac
  1475.                 ;;
  1476.             esac
  1477.             ;;
  1478.         esac
  1479.         case "$redo" in
  1480.         '')
  1481.             case "$type" in
  1482.             File)
  1483.                 if test -f "$ansexp"; then
  1484.                     type=''
  1485.                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
  1486.                 then
  1487.                     echo "($value is not a plain file, but that's ok.)"
  1488.                     type=''
  1489.                 fi
  1490.                 ;;
  1491.             Directory)
  1492.                 if test -d "$ansexp"; then
  1493.                     type=''
  1494.                 fi
  1495.                 ;;
  1496.             Locate)
  1497.                 if test -d "$value"; then
  1498.                     echo "(Looking for $loc_file in directory $value.)"
  1499.                     value="$value/$loc_file"
  1500.                 fi
  1501.                 if test -f "$value"; then
  1502.                     type=''
  1503.                 fi
  1504.                 case "$nopath_ok" in
  1505.                 true)    case "$value" in
  1506.                     */*) ;;
  1507.                     *)    echo "Assuming $value will be in people's path."
  1508.                         type=''
  1509.                         ;;
  1510.                     esac
  1511.                     ;;
  1512.                 esac
  1513.                 ;;
  1514.             esac
  1515.  
  1516.             case "$skip" in
  1517.             true) type='';
  1518.             esac
  1519.  
  1520.             case "$type" in
  1521.             '') ;;
  1522.             *)
  1523.                 if test "$fastread" = yes; then
  1524.                     dflt=y
  1525.                 else
  1526.                     dflt=n
  1527.                 fi
  1528.                 rp="$what $value doesn't exist.  Use that name anyway?"
  1529.                 . UU/myread
  1530.                 dflt=''
  1531.                 case "$ans" in
  1532.                 y*) type='';;
  1533.                 *) echo " ";;
  1534.                 esac
  1535.                 ;;
  1536.             esac
  1537.             ;;
  1538.         esac
  1539.         ;;
  1540.     esac
  1541. done
  1542. cd UU
  1543. ans="$value"
  1544. rp="$orig_rp"
  1545. dflt="$orig_dflt"
  1546. EOSC
  1547.  
  1548. : What should the include directory be ?
  1549. echo " "
  1550. $echo $n "Hmm...  $c"
  1551. dflt='/usr/include'
  1552. incpath=''
  1553. mips_type=''
  1554. if $test -f /bin/mips && /bin/mips; then
  1555.     echo "Looks like a MIPS system..."
  1556.     $cat >usr.c <<'EOCP'
  1557. #ifdef SYSTYPE_BSD43
  1558. /bsd43
  1559. #endif
  1560. EOCP
  1561.     if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
  1562.         dflt='/bsd43/usr/include'
  1563.         incpath='/bsd43'
  1564.         mips_type='BSD 4.3'
  1565.     else
  1566.         mips_type='System V'
  1567.     fi
  1568.     $rm -f usr.c usr.out
  1569.     echo "and you're compiling with the $mips_type compiler and libraries."
  1570. else
  1571.     echo "Doesn't look like a MIPS system."
  1572.     echo "exit 1" >mips
  1573.     chmod +x mips
  1574.     $eunicefix mips
  1575. fi
  1576. echo " "
  1577. case "$usrinc" in
  1578. '') ;;
  1579. *) dflt="$usrinc";;
  1580. esac
  1581. fn=d/
  1582. rp='Where are the include files you want to use?'
  1583. . ./getfile
  1584. usrinc="$ans"
  1585.  
  1586. : see how we invoke the C preprocessor
  1587. echo " "
  1588. echo "Now, how can we feed standard input to your C preprocessor..." >&4
  1589. cat <<'EOT' >testcpp.c
  1590. #define ABC abc
  1591. #define XYZ xyz
  1592. ABC.XYZ
  1593. EOT
  1594. cd ..
  1595. echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
  1596. chmod 755 cppstdin
  1597. wrapper=`pwd`/cppstdin
  1598. ok='false'
  1599. cd UU
  1600.  
  1601. if $test "X$cppstdin" != "X" && \
  1602.     $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
  1603.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
  1604. then
  1605.     echo "You used to use $cppstdin $cppminus so we'll use that again."
  1606.     case "$cpprun" in
  1607.     '') echo "But let's see if we can live without a wrapper..." ;;
  1608.     *)
  1609.         if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
  1610.             $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
  1611.         then
  1612.             echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
  1613.             ok='true'
  1614.         else
  1615.             echo "(However, $cpprun $cpplast does not work, let's see...)"
  1616.         fi
  1617.         ;;
  1618.     esac
  1619. else
  1620.     case "$cppstdin" in
  1621.     '') ;;
  1622.     *)
  1623.         echo "Good old $cppstdin $cppminus does not seem to be of any help..."
  1624.         ;;
  1625.     esac
  1626. fi
  1627.  
  1628. if $ok; then
  1629.     : nothing
  1630. elif echo 'Maybe "'"$cc"' -E" will work...'; \
  1631.     $cc -E <testcpp.c >testcpp.out 2>&1; \
  1632.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1633.     echo "Yup, it does."
  1634.     x_cpp="$cc -E"
  1635.     x_minus='';
  1636. elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
  1637.     $cc -E - <testcpp.c >testcpp.out 2>&1; \
  1638.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1639.     echo "Yup, it does."
  1640.     x_cpp="$cc -E"
  1641.     x_minus='-';
  1642. elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
  1643.     $cc -P <testcpp.c >testcpp.out 2>&1; \
  1644.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1645.     echo "Yipee, that works!"
  1646.     x_cpp="$cc -P"
  1647.     x_minus='';
  1648. elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
  1649.     $cc -P - <testcpp.c >testcpp.out 2>&1; \
  1650.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1651.     echo "At long last!"
  1652.     x_cpp="$cc -P"
  1653.     x_minus='-';
  1654. elif echo 'No such luck, maybe "'$cpp'" will work...'; \
  1655.     $cpp <testcpp.c >testcpp.out 2>&1; \
  1656.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1657.     echo "It works!"
  1658.     x_cpp="$cpp"
  1659.     x_minus='';
  1660. elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
  1661.     $cpp - <testcpp.c >testcpp.out 2>&1; \
  1662.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1663.     echo "Hooray, it works!  I was beginning to wonder."
  1664.     x_cpp="$cpp"
  1665.     x_minus='-';
  1666. elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
  1667.     $wrapper <testcpp.c >testcpp.out 2>&1; \
  1668.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1669.     x_cpp="$wrapper"
  1670.     x_minus=''
  1671.     echo "Eureka!"
  1672. else
  1673.     dflt=''
  1674.     rp="No dice.  I can't find a C preprocessor.  Name one:"
  1675.     . ./myread
  1676.     x_cpp="$ans"
  1677.     x_minus=''
  1678.     $x_cpp <testcpp.c >testcpp.out 2>&1
  1679.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1680.         echo "OK, that will do." >&4
  1681.     else
  1682. echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
  1683.         exit 1
  1684.     fi
  1685. fi
  1686.  
  1687. case "$ok" in
  1688. false)
  1689.     cppstdin="$x_cpp"
  1690.     cppminus="$x_minus"
  1691.     cpprun="$x_cpp"
  1692.     cpplast="$x_minus"
  1693.     set X $x_cpp
  1694.     shift
  1695.     case "$1" in
  1696.     "$cpp")
  1697.         echo "Perhaps can we force $cc -E using a wrapper..."
  1698.         if $wrapper <testcpp.c >testcpp.out 2>&1; \
  1699.             $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
  1700.         then
  1701.             echo "Yup, we can."
  1702.             cppstdin="$wrapper"
  1703.             cppminus='';
  1704.         else
  1705.             echo "Nope, we'll have to live without it..."
  1706.         fi
  1707.         ;;
  1708.     esac
  1709.     case "$cpprun" in
  1710.     "$wrapper")
  1711.         cpprun=''
  1712.         cpplast=''
  1713.         ;;
  1714.     esac
  1715.     ;;
  1716. esac
  1717.  
  1718. case "$cppstdin" in
  1719. "$wrapper") ;;
  1720. *) $rm -f $wrapper;;
  1721. esac
  1722. $rm -f testcpp.c testcpp.out
  1723.  
  1724. : determine optimize, if desired, or use for debug flag also
  1725. case "$optimize" in
  1726. ' ') dflt='none';;
  1727. '') dflt='-O';;
  1728. *) dflt="$optimize";;
  1729. esac
  1730. $cat <<EOH
  1731.  
  1732. Some C compilers have problems with their optimizers, by default, $package
  1733. compiles with the -O flag to use the optimizer.  Alternately, you might want
  1734. to use the symbolic debugger, which uses the -g flag (on traditional Unix
  1735. systems).  Either flag can be specified here.  To use neither flag, specify
  1736. the word "none".
  1737.  
  1738. EOH
  1739. rp="What optimizer/debugger flag should be used?"
  1740. . ./myread
  1741. optimize="$ans"
  1742. case "$optimize" in
  1743. 'none') optimize=" ";;
  1744. esac
  1745.  
  1746. dflt=''
  1747. case "$ccflags" in
  1748. '')    case "$cc" in
  1749.     *gcc*)
  1750.         if $test "$gccversion" = '1'; then
  1751.             dflt='-fpcc-struct-return'
  1752.         fi
  1753.         ;;
  1754.     esac
  1755.     case "$optimize" in
  1756.     *-g*) dflt="$dflt -DDEBUG";;
  1757.     esac
  1758.     case "$cc" in
  1759.     *gcc*)    if test -d /etc/conf/kconfig.d &&
  1760.           $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
  1761.         then
  1762.             dflt="$dflt -posix"
  1763.         fi
  1764.         ;;
  1765.     esac
  1766.     ;;
  1767. esac
  1768.  
  1769. case "$mips_type" in
  1770. *BSD*) ;;
  1771. '') ;;
  1772. *) inclwanted="$inclwanted $usrinc/bsd";;
  1773. esac
  1774. for thisincl in $inclwanted; do
  1775.     if $test -d $thisincl; then
  1776.         if $test x$thisincl != x$usrinc; then
  1777.             case "$dflt" in
  1778.             *$thisincl*);;
  1779.             *) dflt="$dflt -I$thisincl";;
  1780.             esac
  1781.         fi
  1782.     fi
  1783. done
  1784.  
  1785. inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
  1786.     xxx=true;
  1787. elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
  1788.     xxx=true;
  1789. else
  1790.     xxx=false;
  1791. fi;
  1792. if $xxx; then
  1793.     case "$dflt" in
  1794.     *$2*);;
  1795.     *) dflt="$dflt -D$2";;
  1796.     esac;
  1797. fi'
  1798.  
  1799. if ./osf1; then
  1800.     set signal.h __LANGUAGE_C__; eval $inctest
  1801. else
  1802.     set signal.h LANGUAGE_C; eval $inctest
  1803. fi
  1804. set signal.h NO_PROTOTYPE; eval $inctest
  1805. set signal.h _NO_PROTO; eval $inctest
  1806.  
  1807. case "$dflt" in
  1808. '') dflt=none;;
  1809. esac
  1810. case "$ccflags" in
  1811. '') ;;
  1812. *) dflt="$ccflags";;
  1813. esac
  1814. $cat <<EOH
  1815.  
  1816. Your C compiler may want other flags.  For this question you should include
  1817. -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
  1818. but you should NOT include libraries or ld flags like -lwhatever.  If you
  1819. want $package to honor its debug switch, you should include -DDEBUG here.
  1820. To use no flags, specify the word "none".
  1821.  
  1822. EOH
  1823. set X $dflt
  1824. shift
  1825. dflt=${1+"$@"}
  1826. rp="Any additional cc flags?"
  1827. . ./myread
  1828. case "$ans" in
  1829. none) ccflags='';;
  1830. *) ccflags="$ans";;
  1831. esac
  1832.  
  1833. : the following weeds options from ccflags that are of no interest to cpp
  1834. cppflags="$ccflags"
  1835. case "$cc" in
  1836. *gcc*)
  1837.     if $test "$gccversion" = "1"; then
  1838.         cppflags="$cppflags -D__GNUC__"
  1839.     fi
  1840.     ;;
  1841. esac
  1842. case "$mips_type" in
  1843. '');;
  1844. *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
  1845. esac
  1846. case "$cppflags" in
  1847. '');;
  1848. *)
  1849.     echo " "
  1850.     echo "Let me guess what the preprocessor flags are..." >&4
  1851.     set X $cppflags
  1852.     shift
  1853.     cppflags=''
  1854.     $cat >cpp.c <<'EOM'
  1855. #define BLURFL foo
  1856.  
  1857. BLURFL xx LFRULB
  1858. EOM
  1859.     previous=''
  1860.     for flag in $*
  1861.     do
  1862.         case "$flag" in
  1863.         -*) ftry="$flag";;
  1864.         *) ftry="$previous $flag";;
  1865.         esac
  1866.         if $cppstdin -DLFRULB=bar $ftry $cppminus <cpp.c \
  1867.             >cpp1.out 2>/dev/null && \
  1868.             $cpprun -DLFRULB=bar $ftry $cpplast <cpp.c \
  1869.             >cpp2.out 2>/dev/null && \
  1870.             $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
  1871.             $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
  1872.         then
  1873.             cppflags="$cppflags $ftry"
  1874.             previous=''
  1875.         else
  1876.             previous="$flag"
  1877.         fi
  1878.     done
  1879.     set X $cppflags
  1880.     shift
  1881.     cppflags=${1+"$@"}
  1882.     case "$cppflags" in
  1883.     *-*)  echo "They appear to be: $cppflags";;
  1884.     esac
  1885.     $rm -f cpp.c cpp?.out
  1886.     ;;
  1887. esac
  1888.  
  1889. : flags used in final linking phase
  1890. case "$ldflags" in
  1891. '') if venix; then
  1892.         dflt='-i -z'
  1893.     else
  1894.         dflt='none'
  1895.     fi
  1896.     case "$ccflags" in
  1897.     *-posix*) dflt="$dflt -posix" ;;
  1898.     esac
  1899.     ;;
  1900. *) dflt="$ldflags";;
  1901. esac
  1902. echo " "
  1903. rp="Any additional ld flags (NOT including libraries)?"
  1904. . ./myread
  1905. case "$ans" in
  1906. none) ldflags='';;
  1907. *) ldflags="$ans";;
  1908. esac
  1909. rmlist="$rmlist pdp11"
  1910.  
  1911. : Initialize h_fcntl
  1912. h_fcntl=false
  1913.  
  1914. : Initialize h_sysfile
  1915. h_sysfile=false
  1916.  
  1917. : Set private lib path
  1918. case "$plibpth" in
  1919. '') if mips; then
  1920.         plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
  1921.     fi;;
  1922. esac
  1923. case "$libpth" in
  1924. ' ') dlist='';;
  1925. '') dlist="$plibpth $glibpth";;
  1926. *) dlist="$libpth";;
  1927. esac
  1928.  
  1929. : Now check and see which directories actually exist, avoiding duplicates
  1930. libpth=''
  1931. for xxx in $dlist
  1932. do
  1933.     if $test -d $xxx; then
  1934.         case " $libpth " in
  1935.         *" $xxx "*) ;;
  1936.         *) libpth="$libpth $xxx";;
  1937.         esac
  1938.     fi
  1939. done
  1940. $cat <<'EOM'
  1941.  
  1942. Some systems have incompatible or broken versions of libraries.  Among
  1943. the directories listed in the question below, please remove any you
  1944. know not to be holding relevant libraries, and add any that are needed.
  1945. Say "none" for none.
  1946.  
  1947. EOM
  1948. case "$libpth" in
  1949. '') dflt='none';;
  1950. *)
  1951.     set X $libpth
  1952.     shift
  1953.     dflt=${1+"$@"}
  1954.     ;;
  1955. esac
  1956. rp="Directories to use for library searches?"
  1957. . ./myread
  1958. case "$ans" in
  1959. none) libpth=' ';;
  1960. *) libpth="$ans";;
  1961. esac
  1962.  
  1963. : compute shared library extension
  1964. echo " "
  1965. case "$so" in
  1966. '')
  1967.     if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
  1968.         dflt='sl'
  1969.     else
  1970.         dflt='so'
  1971.     fi
  1972.     ;;
  1973.     
  1974. *) dflt="$so";;
  1975. esac
  1976. rp='What is the file extension used for shared libraries?'
  1977. . ./myread
  1978. so="$ans"
  1979.  
  1980. : Looking for optional libraries
  1981. echo " "
  1982. echo "Checking for optional libraries..." >&4
  1983. case "$libs" in
  1984. ' '|'') dflt='';;
  1985. *) dflt="$libs";;
  1986. esac
  1987. case "$libswanted" in
  1988. '') libswanted='c_s';;
  1989. esac
  1990. for thislib in $libswanted; do
  1991.     case "$thislib" in
  1992.     dbm) thatlib=ndbm;;
  1993.     *_s) thatlib=NONE;;
  1994.     *) thatlib="${thislib}_s";;
  1995.     esac
  1996.     
  1997.     if xxx=`./loc lib$thislib.a X $libpth`; $test -f "$xxx"; then
  1998.         echo "Found -l$thislib."
  1999.         case " $dflt " in
  2000.         *"-l$thislib "*|*"-l$thatlib "*);;
  2001.         *) dflt="$dflt -l$thislib";;
  2002.         esac
  2003.     elif xxx=`./loc lib$thatlib.a X $libpth`; $test -f "$xxx"; then
  2004.         echo "Found -l$thatlib."
  2005.         case " $dflt " in
  2006.         *"-l$thatlib "*);;
  2007.         *) dflt="$dflt -l$thatlib";;
  2008.         esac
  2009.     elif xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`; $test -f "$xxx"; then
  2010.         echo "Found -l$thislib (shared only)."
  2011.         case " $dflt " in
  2012.         *"-l$thislib "*|*"-l$thatlib "*);;
  2013.         *) dflt="$dflt -l$thislib";;
  2014.         esac
  2015.     elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
  2016.         echo "Found -l$thislib (shared only)."
  2017.         case " $dflt " in
  2018.         *"-l$thislib "*|*"-l$thatlib "*);;
  2019.         *) dflt="$dflt -l$thislib";;
  2020.         esac
  2021.     elif xxx=`./loc Slib$thislib.a X $xlibpth`; $test -f "$xxx"; then
  2022.         echo "Found -l$thislib."
  2023.         case " $dflt " in
  2024.         *"-l$thislib "*|*"-l$thatlib "*);;
  2025.         *) dflt="$dflt -l$thislib";;
  2026.         esac
  2027.     elif xxx=`./loc Slib$thatlib.a X $xlibpth`; $test -f "$xxx"; then
  2028.         echo "Found -l$thatlib."
  2029.         case " $dflt " in
  2030.         *"-l$thatlib "*);;
  2031.         *) dflt="$dflt -l$thatlib";;
  2032.         esac
  2033.     elif xxx=`./loc lib$thatlib.$so X $libpth`; $test -f "$xxx"; then
  2034.         echo "Found -l$thatlib (shared only)."
  2035.         case "$dflt" in
  2036.         *-l$thislib*|*-l$thatlib*);;
  2037.         *) dflt="$dflt -l$thatlib";;
  2038.         esac
  2039.     else
  2040.         echo "No -l$thislib."
  2041.     fi
  2042. done
  2043. set X $dflt
  2044. shift
  2045. dflt="$*"
  2046. case "$libs" in
  2047. '') dflt="$dflt";;
  2048. *) dflt="$libs";;
  2049. esac
  2050. case "$dflt" in
  2051. ' '|'') dflt='none';;
  2052. esac
  2053.  
  2054. $cat <<EOM
  2055.  
  2056. Some versions of Unix support shared libraries, which make executables smaller
  2057. but make load time slightly longer.
  2058.  
  2059. On some systems, mostly newer Unix System V's, the shared library is included
  2060. by putting the option "-lc_s" as the last thing on the cc command line when
  2061. linking.  Other systems use shared libraries by default.  There may be other
  2062. libraries needed to compile $package on your machine as well.  If your system
  2063. needs the "-lc_s" option, include it here.  Include any other special libraries
  2064. here as well.  Say "none" for none.
  2065. EOM
  2066.  
  2067. echo " "
  2068. rp="Any additional libraries?"
  2069. . ./myread
  2070. case "$ans" in
  2071. none) libs=' ';;
  2072. *) libs="$ans";;
  2073. esac
  2074.  
  2075. : see if nm is to be used to determine whether a symbol is defined or not
  2076. case "$usenm" in
  2077. '')
  2078.     dflt=`egrep 'inlibc|csym' ../Configure | wc -l 2>/dev/null`
  2079.     if $test $dflt -gt 20; then
  2080.         dflt=y
  2081.     else
  2082.         dflt=n
  2083.     fi
  2084.     ;;
  2085. *)
  2086.     case "$usenm" in
  2087.     true) dflt=y;;
  2088.     *) dflt=n;;
  2089.     esac
  2090.     ;;
  2091. esac
  2092. $cat <<EOM
  2093.  
  2094. I can use 'nm' to extract the symbols from your C libraries. This is a time
  2095. consuming task which may generate huge output on the disk (up to 3 megabytes)
  2096. but that should make the symbols extraction faster. The alternative is to skip
  2097. the 'nm' extraction part and to compile a small test program instead to
  2098. determine whether each symbol is present. If you have a fast C compiler and/or
  2099. if your 'nm' output cannot be parsed, this may be the best solution.
  2100.  
  2101. EOM
  2102. rp='Shall I use nm to extract C symbols from the libraries?'
  2103. . ./myread
  2104. case "$ans" in
  2105. n|N) usenm=false;;
  2106. *) usenm=true;;
  2107. esac
  2108.  
  2109. runnm=$usenm
  2110. case "$reuseval" in
  2111. true) runnm=false;;
  2112. esac
  2113.  
  2114. : nm options which may be necessary
  2115. case "$nm_opt" in
  2116. '') if $test -f /mach_boot; then
  2117.         nm_opt=''
  2118.     elif $test -d /usr/ccs/lib; then
  2119.         nm_opt='-p'
  2120.     elif $test -f /dgux; then
  2121.         nm_opt='-p'
  2122.     else
  2123.         nm_opt=''
  2124.     fi;;
  2125. esac
  2126.  
  2127. case "$runnm" in
  2128. true)
  2129. : get list of predefined functions in a handy place
  2130. echo " "
  2131. case "$libc" in
  2132. '') libc=unknown
  2133.     case "$libs" in
  2134.     *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
  2135.     esac
  2136.     ;;
  2137. esac
  2138. libnames='';
  2139. case "$libs" in
  2140. '') ;;
  2141. *)  for thislib in $libs; do
  2142.     case "$thislib" in
  2143.     -l*)
  2144.         thislib=`expr X$thislib : 'X-l\(.*\)'`
  2145.         if try=`./loc lib$thislib.a X $libpth`; $test -f "$try"; then
  2146.             :
  2147.         elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
  2148.             :
  2149.         elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
  2150.             :
  2151.         elif try=`./loc Slib$thislib.a X $xlibpth`; $test -f "$try"; then
  2152.             :
  2153.         elif try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
  2154.             :
  2155.         elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
  2156.             :
  2157.         else
  2158.             try=''
  2159.         fi
  2160.         libnames="$libnames $try"
  2161.         ;;
  2162.     *) libnames="$libnames $thislib" ;;
  2163.     esac
  2164.     done
  2165.     ;;
  2166. esac
  2167. xxx=normal
  2168. case "$libc" in
  2169. unknown)
  2170.     set /usr/ccs/lib/libc.$so
  2171.     $test -r $1 || set /usr/lib/libc.$so
  2172.     $test -r $1 || set /usr/shlib/libc.$so
  2173.     $test -r $1 || set /usr/lib/libc.$so.[0-9]*
  2174.     $test -r $1 || set /lib/libc.$so
  2175.     $test -r $1 || set /lib/libsys_s.a
  2176.     eval set \$$#
  2177.     ;;
  2178. *)
  2179.     set blurfl
  2180.     ;;
  2181. esac
  2182. if $test -r "$1"; then
  2183.     echo "Your (shared) C library seems to be in $1."
  2184.     libc="$1"
  2185. elif $test -r /lib/libc && $test -r /lib/clib; then
  2186.     echo "Your C library seems to be in both /lib/clib and /lib/libc."
  2187.     xxx=apollo
  2188.     libc='/lib/clib /lib/libc'
  2189.     if $test -r /lib/syslib; then
  2190.         echo "(Your math library is in /lib/syslib.)"
  2191.         libc="$libc /lib/syslib"
  2192.     fi
  2193. elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
  2194.     echo "Your C library seems to be in $libc, as you said before."
  2195. elif $test -r $incpath/usr/lib/libc.a; then
  2196.     libc=$incpath/usr/lib/libc.a;
  2197.     echo "Your C library seems to be in $libc.  That's fine."
  2198. elif $test -r /lib/libc.a; then
  2199.     libc=/lib/libc.a;
  2200.     echo "Your C library seems to be in $libc.  You're normal."
  2201. else
  2202.     if tans=`./loc libc.a blurfl/dyick $libpth`; $test -r "$tans"; then
  2203.         :
  2204.     elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
  2205.         libnames="$libnames "`./loc clib blurfl/dyick $libpth`
  2206.     elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
  2207.         :
  2208.     elif tans=`./loc Slibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
  2209.         :
  2210.     elif tans=`./loc Mlibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
  2211.         :
  2212.     else
  2213.         tans=`./loc Llibc.a blurfl/dyick $xlibpth`
  2214.     fi
  2215.     if $test -r "$tans"; then
  2216.         echo "Your C library seems to be in $tans, of all places."
  2217.         libc=$tans
  2218.     else
  2219.         libc='blurfl'
  2220.     fi
  2221. fi
  2222. if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
  2223.     dflt="$libc"
  2224.     cat <<EOM
  2225.  
  2226. If the guess above is wrong (which it might be if you're using a strange
  2227. compiler, or your machine supports multiple models), you can override it here.
  2228.  
  2229. EOM
  2230. else
  2231.     dflt=''
  2232.     echo $libpth | tr ' ' '\012' | sort | uniq > libpath
  2233.     cat >&4 <<EOM
  2234. I can't seem to find your C library.  I've looked in the following places:
  2235.  
  2236. EOM
  2237.     $sed 's/^/    /' libpath
  2238.     cat <<EOM
  2239.  
  2240. None of these seems to contain your C library. I need to get its name...
  2241.  
  2242. EOM
  2243. fi
  2244. fn=f
  2245. rp='Where is your C library?'
  2246. . ./getfile
  2247. libc="$ans"
  2248.  
  2249. echo " "
  2250. echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
  2251. set X `cat libnames`
  2252. shift
  2253. xxx=files
  2254. case $# in 1) xxx=file; esac
  2255. echo "Extracting names from the following $xxx for later perusal:" >&4
  2256. echo " "
  2257. $sed 's/^/    /' libnames >&4
  2258. echo " "
  2259. $echo $n "This may take a while...$c" >&4
  2260.  
  2261. nm $nm_opt $* 2>/dev/null >libc.tmp
  2262. $echo $n ".$c"
  2263. $grep fprintf libc.tmp > libc.ptf
  2264. xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
  2265. xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
  2266. if com="$sed -n -e 's/^.* [ADTSI]  *_[_.]*//p' -e 's/^.* [ADTSI] //p'";\
  2267.     eval $xscan;\
  2268.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2269.         eval $xrun
  2270. elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
  2271.     eval $xscan;\
  2272.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2273.         eval $xrun
  2274. elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
  2275.     eval $xscan;\
  2276.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2277.         eval $xrun
  2278. elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
  2279.     eval $xscan;\
  2280.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2281.         eval $xrun
  2282. elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
  2283.     eval $xscan;\
  2284.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2285.         eval $xrun
  2286. elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
  2287.     eval $xscan;\
  2288.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2289.         eval $xrun
  2290. elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
  2291.                 -e '/ file/d' -e 's/^\([^     ]*\).*/\1/p'";\
  2292.     eval $xscan;\
  2293.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2294.         eval $xrun
  2295. elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
  2296.     eval $xscan;\
  2297.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2298.         eval $xrun
  2299. elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
  2300.     eval $xscan;\
  2301.     $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2302.         eval $xrun
  2303. else
  2304.     nm -p $* 2>/dev/null >libc.tmp
  2305.     com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  2306.     eval "<libc.tmp $com >libc.list"
  2307.     if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  2308.         nm_opt='-p'
  2309.         echo "done" >&4
  2310.     else
  2311.         echo " "
  2312.         echo "nm didn't seem to work right. Trying ar instead..." >&4
  2313.         com=''
  2314.         if ar t $libc > libc.tmp; then
  2315.             for thisname in $libnames; do
  2316.                 ar t $thisname >>libc.tmp
  2317.             done
  2318.             $sed -e 's/\.o$//' < libc.tmp > libc.list
  2319.             echo "Ok." >&4
  2320.         else
  2321.             echo "ar didn't seem to work right." >&4
  2322.             echo "Maybe this is a Cray...trying bld instead..." >&4
  2323.             if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  2324.                 for thisname in $libnames; do
  2325.                     bld t $libnames | \
  2326.                     $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  2327.                     ar t $thisname >>libc.tmp
  2328.                 done
  2329.                 echo "Ok." >&4
  2330.             else
  2331.                 echo "That didn't work either.  Giving up." >&4
  2332.                 exit 1
  2333.             fi
  2334.         fi
  2335.     fi
  2336. fi
  2337. nm_extract="$com"
  2338. if $test -f /lib/syscalls.exp; then
  2339.     echo " "
  2340.     echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
  2341.     $sed -n 's/^\([^     ]*\)[     ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
  2342. fi
  2343. ;;
  2344. esac
  2345. $rm -f libnames libpath
  2346.  
  2347. : is a C symbol defined?
  2348. csym='tlook=$1;
  2349. case "$3" in
  2350. -v) tf=libc.tmp; tc=""; tdc="";;
  2351. -a) tf=libc.tmp; tc="[0]"; tdc=[];;
  2352. *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
  2353. esac;
  2354. tx=yes;
  2355. case "$reuseval-$4" in
  2356. true-) ;;
  2357. true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
  2358. esac;
  2359. case "$tx" in
  2360. yes)
  2361.     case "$runnm" in
  2362.     true)
  2363.         if $contains $tlook $tf >/dev/null 2>&1;
  2364.         then tval=true;
  2365.         else tval=false;
  2366.         fi;;
  2367.     *)
  2368.         echo "main() { extern int $1$tdc; printf(\"%d\", $1$tc); }" > t.c;
  2369.         if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
  2370.         then tval=true;
  2371.         else tval=false;
  2372.         fi;
  2373.         $rm -f t t.c;;
  2374.     esac;;
  2375. *)
  2376.     case "$tval" in
  2377.     $define) tval=true;;
  2378.     *) tval=false;;
  2379.     esac;;
  2380. esac;
  2381. eval "$2=$tval"'
  2382.  
  2383. : set up the script used to warn in case of inconsistency
  2384. cat <<'EOSC' >whoa
  2385. dflt=y
  2386. echo " "
  2387. echo "*** WHOA THERE!!! ***" >&4
  2388. echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
  2389. rp="    Keep the $hint value?"
  2390. . ./myread
  2391. case "$ans" in
  2392. y) td=$was; tu=$was;;
  2393. esac
  2394. EOSC
  2395.  
  2396. : define an is-in-libc? function
  2397. inlibc='echo " "; td=$define; tu=$undef;
  2398. sym=$1; var=$2; eval "was=\$$2";
  2399. tx=yes;
  2400. case "$reuseval$was" in
  2401. true) ;;
  2402. true*) tx=no;;
  2403. esac;
  2404. case "$tx" in
  2405. yes)
  2406.     set $sym tres -f;
  2407.     eval $csym;
  2408.     case "$tres" in
  2409.     true)
  2410.         echo "$sym() found." >&4;
  2411.         case "$was" in $undef) . whoa; esac; eval "$var=\$td";;
  2412.     *)
  2413.         echo "$sym() NOT found." >&4;
  2414.         case "$was" in $define) . whoa; esac; eval "$var=\$tu";;
  2415.     esac;;
  2416. *)
  2417.     case "$was" in
  2418.     $define) echo "$sym() found." >&4;;
  2419.     *) echo "$sym() NOT found." >&4;;
  2420.     esac;;
  2421. esac'
  2422.  
  2423. : determine filename position in cpp output
  2424. echo " "
  2425. echo "Computing filename position in cpp output for #include directives..." >&4
  2426. echo '#include <stdio.h>' > foo.c
  2427. $cat >fieldn <<EOF
  2428. $startsh
  2429. $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
  2430. $grep '^[     ]*#.*stdio\.h' | \
  2431. while read cline; do
  2432.     pos=1
  2433.     set \$cline
  2434.     while $test \$# -gt 0; do
  2435.         if $test -r \`echo \$1 | $tr -d '"'\`; then
  2436.             echo "\$pos"
  2437.             exit 0
  2438.         fi
  2439.         shift
  2440.         pos=\`expr \$pos + 1\`
  2441.     done
  2442. done
  2443. EOF
  2444. chmod +x fieldn
  2445. fieldn=`./fieldn`
  2446. $rm -f foo.c fieldn
  2447. case $fieldn in
  2448. '') pos='???';;
  2449. 1) pos=first;;
  2450. 2) pos=second;;
  2451. 3) pos=third;;
  2452. *) pos="${fieldn}th";;
  2453. esac
  2454. echo "Your cpp writes the filename in the $pos field of the line."
  2455.  
  2456. : locate header file
  2457. $cat >findhdr <<EOF
  2458. $startsh
  2459. wanted=\$1
  2460. name=''
  2461. if test -f $usrinc/\$wanted; then
  2462.     echo "$usrinc/\$wanted"
  2463.     exit 0
  2464. fi
  2465. awkprg='{ print \$$fieldn }'
  2466. echo "#include <\$wanted>" > foo\$\$.c
  2467. $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
  2468. $grep "^[     ]*#.*\$wanted" | \
  2469. while read cline; do
  2470.     name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
  2471.     case "\$name" in
  2472.     */\$wanted) echo "\$name"; exit 0;;
  2473.     *) name='';;
  2474.     esac;
  2475. done;
  2476. $rm -f foo\$\$.c;
  2477. case "\$name" in
  2478. '') exit 1;;
  2479. esac
  2480. EOF
  2481. chmod +x findhdr
  2482.  
  2483. : access call always available on UNIX
  2484. set access d_access
  2485. eval $inlibc
  2486.  
  2487. : locate the flags for 'access()'
  2488. case "$d_access" in
  2489. "$define")
  2490.     echo " "
  2491.     $cat >access.c <<'EOCP'
  2492. #include <sys/types.h>
  2493. #ifdef I_FCNTL
  2494. #include <fcntl.h>
  2495. #endif
  2496. #ifdef I_SYS_FILE
  2497. #include <sys/file.h>
  2498. #endif
  2499. #ifdef I_UNISTD
  2500. #include <unistd.h>
  2501. #endif
  2502. main() {
  2503.     exit(R_OK);
  2504. }
  2505. EOCP
  2506.     : check sys/file.h first, no particular reason here
  2507.     if $test `./findhdr sys/file.h` && \
  2508.         $cc $cppflags -DI_SYS_FILE access.c -o access >/dev/null 2>&1 ; then
  2509.         h_sysfile=true;
  2510.         echo "<sys/file.h> defines the *_OK access constants." >&4
  2511.     elif $test `./findhdr fcntl.h` && \
  2512.         $cc $cppflags -DI_FCNTL access.c -o access >/dev/null 2>&1 ; then
  2513.         h_fcntl=true;
  2514.         echo "<fcntl.h> defines the *_OK access constants." >&4
  2515.     elif $test `./findhdr unistd.h` && \
  2516.         $cc $cppflags -DI_UNISTD access.c -o access >/dev/null 2>&1 ; then
  2517.         echo "<unistd.h> defines the *_OK access constants." >&4
  2518.     else
  2519.         echo "I can't find the four *_OK access constants--I'll use mine." >&4
  2520.     fi
  2521.     ;;
  2522. esac
  2523. $rm -f access*
  2524.  
  2525. : function used to set $1 to $val
  2526. setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
  2527. case "$val$was" in
  2528. $define$undef) . whoa; eval "$var=\$td";;
  2529. $undef$define) . whoa; eval "$var=\$tu";;
  2530. *) eval "$var=$val";;
  2531. esac'
  2532.  
  2533. : check for const keyword
  2534. echo " "
  2535. echo 'Checking to see if your C compiler knows about "const"...' >&4
  2536. $cat >const.c <<'EOCP'
  2537. typedef struct spug { int drokk; } spug;
  2538. main()
  2539. {
  2540.     const char *foo;
  2541.     const spug y;
  2542. }
  2543. EOCP
  2544. if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
  2545.     val="$define"
  2546.     echo "Yup, it does."
  2547. else
  2548.     val="$undef"
  2549.     echo "Nope, it doesn't."
  2550. fi
  2551. set d_const
  2552. eval $setvar
  2553.  
  2554. : see how we invoke the C preprocessor
  2555. $cat <<EOM
  2556.  
  2557. $package needs to be able to preprocess its input files in a mode which
  2558. preserves comments, which is often not the default behaviour.  It should run
  2559. the C preprocessor you will use when compiling your own source code, which
  2560. should be ISO/ANSI C compliant if you want $package to handle the latest
  2561. standard C.  I will try to guess, but I might guess wrongly because it is not
  2562. necessarily the same preprocessor used to build $package.
  2563.  
  2564. EOM
  2565. $cat <<'EOT' >testcpp.c
  2566. #define ABC abc
  2567. #define XYZ xyz
  2568. ABC.XYZ
  2569. /* comment */
  2570. EOT
  2571. :
  2572. if $test "X$cppfilecom" != "X" && \
  2573.     $cppfilecom testcpp.c </dev/null >testcpp.out 2>/dev/null && \
  2574.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2575.     $contains comment testcpp.out >/dev/null 2>&1
  2576. then
  2577.     echo "You used to use $cppfilecom so we'll use that again."
  2578. elif echo 'Maybe "'$cc' -E -C" will work...' && \
  2579.     $cc -E -C testcpp.c </dev/null >testcpp.out 2>/dev/null && \
  2580.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2581.     $contains comment testcpp.out >/dev/null 2>&1
  2582. then
  2583.     echo "It works!"
  2584.     cppfilecom="$cc -E -C"
  2585. elif echo 'Nope...maybe "'"$cc"' -P -C" will work...' && \
  2586.     $cc -P -C testcpp.c </dev/null >testcpp.out 2>/dev/null && \
  2587.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2588.     $contains comment testcpp.out >/dev/null 2>&1
  2589. then
  2590.     echo "Yup, that does."
  2591.     cppfilecom="$cc -P -C"
  2592. elif echo 'No such luck, maybe "'"$cpp"' -C" will work...' && \
  2593.     $cpp -C testcpp.c </dev/null >testcpp.out 2>/dev/null && \
  2594.     $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2595.     $contains comment testcpp.out >/dev/null 2>&1
  2596. then
  2597.     echo "Yup, it does."
  2598.     cppfilecom="$cpp -C"
  2599. else
  2600.     cppfilecom=''
  2601.     $cat <<'EOM'
  2602. I can't find a C preprocessor that will preserve comments. Please name one.
  2603. EOM
  2604. fi
  2605. :
  2606. dflt="$cppfilecom"
  2607. cont=true
  2608. while $test "$cont" ; do
  2609.     echo " "
  2610.     rp="How should $package run your preprocessor preserving comments?"
  2611.     . ./myread
  2612.     cppfilecom="$ans"
  2613.     $cppfilecom testcpp.c >testcpp.out 2>&1
  2614.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2615.         $contains comment testcpp.out >/dev/null 2>&1
  2616.     then
  2617.         echo "OK, that will do."
  2618.         cont=''
  2619.     else
  2620.         echo "Sorry, I can't get that to work."
  2621.     fi
  2622. done
  2623.  
  2624. : Now see if it ignores header files.
  2625. cp testcpp.c testcpp.h
  2626. $cppfilecom testcpp.h >testcpp.out 2>&1
  2627. if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2628.     $contains comment testcpp.out >/dev/null 2>&1
  2629. then
  2630.     echo "Terrific; it processes .h files passed on the command line too."
  2631.     val="$undef"
  2632. else
  2633.     echo "It ignores .h files on the command line; pity."
  2634.     val="$define"
  2635. fi
  2636. set d_cppignhdrs
  2637. eval $setvar
  2638.  
  2639. : Now see how to send stdin to it.
  2640. echo " "
  2641. cp testcpp.c testcpp.h
  2642. $cppfilecom <testcpp.h >testcpp.out 2>&1
  2643. if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2644.     $contains comment testcpp.out >/dev/null 2>&1
  2645. then
  2646.     echo "Great; and it will read stdin if passed no arguments."
  2647.     val="$define"
  2648.     cppstdinflags=''
  2649. else
  2650.     $cppfilecom - <testcpp.h >testcpp.out 2>&1
  2651.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2652.         $contains comment testcpp.out >/dev/null 2>&1
  2653.     then
  2654.         echo "Great; and it can read stdin by passing it '-'."
  2655.         val="$define"
  2656.         cppstdinflags='-'
  2657.     else
  2658.         $cat <<FOO
  2659. Unfortunately, I can't find an easy way to get that preprocessor to read from
  2660. standard input. Do you know any flags I can pass it to get it to do so?
  2661. If that preprocessor can't read directly form standard input, answer 'none'.
  2662.  
  2663. FOO
  2664.     val='dunno'
  2665.     while $test "$val" = "dunno"; do
  2666.         rp='Flags to get preprocessor to read stdin?'
  2667.         dflt='none'
  2668.         . ./myread
  2669.         if $test $ans = 'none'; then
  2670.             echo "Oh well, if $package wants it done, it will do it for itself."
  2671.             val="$undef"
  2672.         else
  2673.             $cppfilecom $ans <testcpp.h >testcpp.out 2>&1
  2674.             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
  2675.                 $contains comment testcpp.out >/dev/null 2>&1
  2676.             then
  2677.                 echo "Good; that works fine."
  2678.                 val="$define"
  2679.                 cppstdinflags="$ans"
  2680.             else
  2681.                 echo "Sorry, I couldn't get that to work."
  2682.             fi
  2683.         fi
  2684.     done
  2685.     fi
  2686. fi
  2687. set d_cppcanstdin
  2688. eval $setvar
  2689.  
  2690. : cleanup cpp test files anyway
  2691. $rm -f testcpp.*
  2692.  
  2693. : see if we can have long filenames
  2694. echo " "
  2695. rmlist="$rmlist /tmp/cf$$"
  2696. $test -d /tmp/cf$$ || mkdir /tmp/cf$$
  2697. first=123456789abcdef
  2698. second=/tmp/cf$$/$first
  2699. $rm -f $first $second
  2700. if (echo hi >$first) 2>/dev/null; then
  2701.     if $test -f 123456789abcde; then
  2702.         echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
  2703.         val="$undef"
  2704.     else
  2705.         if (echo hi >$second) 2>/dev/null; then
  2706.             if $test -f /tmp/cf$$/123456789abcde; then
  2707.                 $cat <<'EOM'
  2708. That's peculiar... You can have filenames longer than 14 characters, but only
  2709. on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
  2710. I shall consider your system cannot support long filenames at all.
  2711. EOM
  2712.                 val="$undef"
  2713.             else
  2714.                 echo 'You can have filenames longer than 14 characters.' >&4
  2715.                 val="$define"
  2716.             fi
  2717.         else
  2718.             $cat <<'EOM'
  2719. How confusing! Some of your filesystems are sane enough to allow filenames
  2720. longer than 14 characters but some others like /tmp can't even think about them.
  2721. So, for now on, I shall assume your kernel does not allow them at all.
  2722. EOM
  2723.             val="$undef"
  2724.         fi
  2725.     fi
  2726. else
  2727.     $cat <<'EOM'
  2728. You can't have filenames longer than 14 chars.  You can't even think about them!
  2729. EOM
  2730.     val="$undef"
  2731. fi 
  2732. set d_flexfnam
  2733. eval $setvar
  2734. $rm -rf /tmp/cf$$ 123456789abcde*
  2735.  
  2736. : see which of string.h or strings.h is needed
  2737. echo " "
  2738. strings=`./findhdr string.h`
  2739. if $test "$strings" && $test -r "$strings"; then
  2740.     echo "Using <string.h> instead of <strings.h>." >&4
  2741.     val="$define"
  2742. else
  2743.     val="$undef"
  2744.     strings=`./findhdr strings.h`
  2745.     if $test "$strings" && $test -r "$strings"; then
  2746.         echo "Using <strings.h> instead of <string.h>." >&4
  2747.     else
  2748.         echo "No string header found -- You'll surely have problems." >&4
  2749.     fi
  2750. fi
  2751. set i_string
  2752. eval $setvar
  2753. case "$i_string" in
  2754. "$undef") strings=`./findhdr strings.h`;;
  2755. *)      strings=`./findhdr string.h`;;
  2756. esac
  2757.  
  2758. : index or strchr
  2759. echo " "
  2760. if set index val -f; eval $csym; $val; then
  2761.     if set strchr val -f d_strchr; eval $csym; $val; then
  2762.         if $contains strchr "$strings" >/dev/null 2>&1 ; then
  2763.             val="$define"
  2764.             vali="$undef"
  2765.             echo "strchr() found." >&4
  2766.         else
  2767.             val="$undef"
  2768.             vali="$define"
  2769.             echo "index() found." >&4
  2770.         fi
  2771.     else
  2772.         val="$undef"
  2773.         vali="$define"
  2774.         echo "index() found." >&4
  2775.     fi
  2776. else
  2777.     if set strchr val -f d_strchr; eval $csym; $val; then
  2778.         val="$define"
  2779.         vali="$undef"
  2780.         echo "strchr() found." >&4
  2781.     else
  2782.         echo "No index() or strchr() found!" >&4
  2783.         val="$undef"
  2784.         vali="$undef"
  2785.     fi
  2786. fi
  2787. set d_strchr; eval $setvar
  2788. val="$vali"
  2789. set d_index; eval $setvar
  2790.  
  2791. : see if link exists
  2792. set link d_link
  2793. eval $inlibc
  2794.  
  2795. : Locate the flags for 'open()'
  2796. echo " "
  2797. $cat >open3.c <<'EOCP'
  2798. #include <sys/types.h>
  2799. #ifdef I_FCNTL
  2800. #include <fcntl.h>
  2801. #endif
  2802. #ifdef I_SYS_FILE
  2803. #include <sys/file.h>
  2804. #endif
  2805. main() {
  2806.     if(O_RDONLY);
  2807. #ifdef O_TRUNC
  2808.     exit(0);
  2809. #else
  2810.     exit(1);
  2811. #endif
  2812. }
  2813. EOCP
  2814. : check sys/file.h first to get FREAD on Sun
  2815. if $test `./findhdr sys/file.h` && \
  2816.         $cc $cppflags "-DI_SYS_FILE" open3.c -o open3 >/dev/null 2>&1 ; then
  2817.     h_sysfile=true;
  2818.     echo "<sys/file.h> defines the O_* constants..." >&4
  2819.     if ./open3; then
  2820.         echo "and you have the 3 argument form of open()." >&4
  2821.         val="$define"
  2822.     else
  2823.         echo "but not the 3 argument form of open().  Oh, well." >&4
  2824.         val="$undef"
  2825.     fi
  2826. elif $test `./findhdr fcntl.h` && \
  2827.         $cc "-DI_FCNTL" open3.c -o open3 >/dev/null 2>&1 ; then
  2828.     h_fcntl=true;
  2829.     echo "<fcntl.h> defines the O_* constants..." >&4
  2830.     if ./open3; then
  2831.         echo "and you have the 3 argument form of open()." >&4
  2832.         val="$define"
  2833.     else
  2834.         echo "but not the 3 argument form of open().  Oh, well." >&4
  2835.         val="$undef"
  2836.     fi
  2837. else
  2838.     val="$undef"
  2839.     echo "I can't find the O_* constant definitions!  You got problems." >&4
  2840. fi
  2841. set d_open3
  2842. eval $setvar
  2843. $rm -f open3*
  2844.  
  2845. : see if strftime exists
  2846. set strftime d_strftime
  2847. eval $inlibc
  2848.  
  2849. : see if strstr exists
  2850. set strstr d_strstr
  2851. eval $inlibc
  2852.  
  2853. : see if symlink exists
  2854. set symlink d_symlink
  2855. eval $inlibc
  2856.  
  2857. : check for volatile keyword
  2858. echo " "
  2859. echo 'Checking to see if your C compiler knows about "volatile"...' >&4
  2860. $cat >try.c <<'EOCP'
  2861. main()
  2862. {
  2863.     typedef struct _goo_struct goo_struct;
  2864.     goo_struct * volatile goo = ((goo_struct *)0);
  2865.     struct _goo_struct {
  2866.         long long_int;
  2867.         int reg_int;
  2868.         char char_var;
  2869.     };
  2870.     typedef unsigned short foo_t;
  2871.     char *volatile foo;
  2872.     volatile int bar;
  2873.     volatile foo_t blech;
  2874.     foo = foo;
  2875. }
  2876. EOCP
  2877. if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
  2878.     val="$define"
  2879.     echo "Yup, it does."
  2880. else
  2881.     val="$undef"
  2882.     echo "Nope, it doesn't."
  2883. fi
  2884. set d_volatile
  2885. eval $setvar
  2886. $rm -f try.*
  2887.  
  2888. : preserve RCS keywords in files with variable substitution, grrr
  2889. Id='$Id'
  2890.  
  2891. : is AFS running?
  2892. echo " "
  2893. if test -d /afs; then
  2894.     echo "AFS may be running... I'll be extra cautious then..." >&4
  2895.     afs=true
  2896. else
  2897.     echo "AFS does not seem to be running..." >&4
  2898.     afs=false
  2899. fi
  2900.  
  2901. : determine root of directory hierarchy where package will be installed.
  2902. case "$prefix" in
  2903. '')
  2904.     dflt=`./loc . /usr/local /usr/local /local /opt /usr`
  2905.     ;;
  2906. *)
  2907.     dflt="$prefix"
  2908.     ;;
  2909. esac
  2910. $cat <<EOM
  2911.  
  2912. By default, $package will be installed in $dflt/bin, manual
  2913. pages under $dflt/man, etc..., i.e. with $dflt as prefix for
  2914. all installation directories. Typically set to /usr/local, but you
  2915. may choose /usr if you wish to install $package among your system
  2916. binaries. If you wish to have binaries under /bin but manual pages
  2917. under /usr/local/man, that's ok: you will be prompted separately
  2918. for each of the installation directories, the prefix being only used
  2919. to set defaults.
  2920.  
  2921. EOM
  2922. fn=d~
  2923. rp='Installation prefix to use?'
  2924. . ./getfile
  2925. prefix="$ans"
  2926.  
  2927. : determine where public executables go
  2928. echo " "
  2929. case "$bin" in
  2930. '')
  2931.     dflt="$prefix/bin"
  2932.     ;;
  2933. *)
  2934.     dflt="$bin"
  2935.     ;;
  2936. esac
  2937. fn=d~
  2938. rp='Pathname where the public executables will reside?'
  2939. . ./getfile
  2940. bin="$ans"
  2941. binexp="$ansexp"
  2942. if $afs; then
  2943.     $cat <<EOM
  2944.  
  2945. Since you are running AFS, I need to distinguish the directory in which
  2946. executables reside from the directory in which they are installed (and from
  2947. which they are presumably copied to the former directory by occult means).
  2948.  
  2949. EOM
  2950.     case "$installbin" in
  2951.     '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
  2952.     *) dflt="$installbin";;
  2953.     esac
  2954.     fn=de~
  2955.     rp='Where will public executables be installed?'
  2956.     . ./getfile
  2957.     installbin="$ans"
  2958. else
  2959.     installbin="$binexp"
  2960. fi
  2961.  
  2962. : check for void type
  2963. echo " "
  2964. $cat >&4 <<EOM
  2965. Checking to see how well your C compiler groks the void type...
  2966.  
  2967.   Support flag bits are:
  2968.     1: basic void declarations.
  2969.     2: arrays of pointers to functions returning void.
  2970.     4: operations between pointers to and addresses of void functions.
  2971.     8: generic void pointers.
  2972.  
  2973. EOM
  2974. case "$voidflags" in
  2975. '')
  2976.     $cat >try.c <<'EOCP'
  2977. #if TRY & 1
  2978. void main() {
  2979. #else
  2980. main() {
  2981. #endif
  2982.     extern void moo();    /* function returning void */
  2983.     void (*goo)();        /* ptr to func returning void */
  2984. #if TRY & 8
  2985.     void *hue;        /* generic ptr */
  2986. #endif
  2987. #if TRY & 2
  2988.     void (*foo[10])();
  2989. #endif
  2990.  
  2991. #if TRY & 4
  2992.     if(goo == moo) {
  2993.         exit(0);
  2994.     }
  2995. #endif
  2996.     exit(0);
  2997. }
  2998. EOCP
  2999.     if $cc -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
  3000.         voidflags=$defvoidused
  3001.     echo "It appears to support void to the level $package wants ($defvoidused)."
  3002.         if $contains warning .out >/dev/null 2>&1; then
  3003.             echo "However, you might get some warnings that look like this:"
  3004.             $cat .out
  3005.         fi
  3006.     else
  3007. echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
  3008.         if $cc -c -DTRY=1 try.c >/dev/null 2>&1 ; then
  3009.             echo "It supports 1..."
  3010.             if $cc -c -DTRY=3 try.c >/dev/null 2>&1 ; then
  3011.                 echo "It also supports 2..."
  3012.                 if $cc -c -DTRY=7 try.c >/dev/null 2>&1 ; then
  3013.                     voidflags=7
  3014.                     echo "And it supports 4 but not 8 definitely."
  3015.                 else
  3016.                     echo "It doesn't support 4..."
  3017.                     if $cc -c -DTRY=11 try.c >/dev/null 2>&1 ; then
  3018.                         voidflags=11
  3019.                         echo "But it supports 8."
  3020.                     else
  3021.                         voidflags=3
  3022.                         echo "Neither does it support 8."
  3023.                     fi
  3024.                 fi
  3025.             else
  3026.                 echo "It does not support 2..."
  3027.                 if $cc -c -DTRY=13 try.c >/dev/null 2>&1 ; then
  3028.                     voidflags=13
  3029.                     echo "But it supports 4 and 8."
  3030.                 else
  3031.                     if $cc -c -DTRY=5 try.c >/dev/null 2>&1 ; then
  3032.                         voidflags=5
  3033.                         echo "And it supports 4 but has not heard about 8."
  3034.                     else
  3035.                         echo "However it supports 8 but not 4."
  3036.                     fi
  3037.                 fi
  3038.             fi
  3039.         else
  3040.             echo "There is no support at all for void."
  3041.             voidflags=0
  3042.         fi
  3043.     fi
  3044. esac
  3045. dflt="$voidflags";
  3046. rp="Your void support flags add up to what?"
  3047. . ./myread
  3048. voidflags="$ans"
  3049. $rm -f try.* .out
  3050.  
  3051. : determine where private executables go
  3052. case "$privlib" in
  3053. '')
  3054.     dflt=$prefix/lib/$package
  3055.     ;;
  3056. *)  dflt="$privlib"
  3057.     ;;
  3058. esac
  3059. $cat <<EOM
  3060.  
  3061. There are some auxiliary files for $package that need to be put into a
  3062. private library directory that is accessible by everyone.
  3063.  
  3064. EOM
  3065. fn=d~+
  3066. rp='Pathname where private library files will reside?'
  3067. . ./getfile
  3068. privlib="$ans"
  3069. privlibexp="$ansexp"
  3070. if $afs; then
  3071.     $cat <<EOM
  3072.  
  3073. Since you are running AFS, I need to distinguish the directory in which
  3074. private files reside from the directory in which they are installed (and from
  3075. which they are presumably copied to the former directory by occult means).
  3076.  
  3077. EOM
  3078.     case "$installprivlib" in
  3079.     '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
  3080.     *) dflt="$installprivlib";;
  3081.     esac
  3082.     fn=de~
  3083.     rp='Where will private files be installed?'
  3084.     . ./getfile
  3085.     installprivlib="$ans"
  3086. else
  3087.     installprivlib="$privlibexp"
  3088. fi
  3089.  
  3090. : determine lexical analyser generator
  3091. case "$lex" in
  3092. '')
  3093.     dflt=lex;;
  3094. *)
  3095.     dflt="$lex";;
  3096. esac
  3097. echo " "
  3098. if $test -f "$flex"; then
  3099.     rp='Which lexical analyser generator (lex or flex) shall I use?'
  3100. else
  3101.     rp='Which lexical analyser generator shall I use?'
  3102. fi
  3103. . ./myread
  3104. lex="$ans"
  3105.  
  3106. : see if we should include -ll
  3107. echo " "
  3108. case "$lex" in
  3109. *flex*)
  3110.     xxx=`./loc libfl.a x $libpth`
  3111.     case "$xxx" in
  3112.     x)
  3113.         echo "No flex library found." >&4
  3114.         liblex=''
  3115.         ;;
  3116.     *)
  3117.         echo "flex library found in $xxx." >&4
  3118.         liblex="$xxx"
  3119.         ;;
  3120.     esac
  3121.     ;;
  3122. *lex)
  3123.     xxx=`./loc libl.a x $libpth`
  3124.     case "$xxx" in
  3125.     x)
  3126.         echo "No lex library found." >&4
  3127.         liblex=''
  3128.         ;;
  3129.     *)
  3130.         echo "lex library found in $xxx." >&4
  3131.         liblex="$xxx"
  3132.         ;;
  3133.     esac
  3134.     ;;
  3135. *)
  3136. echo "You don't seem to have lex, so I won't look for the lex library." >&4
  3137.     liblex=''
  3138.     ;;
  3139. esac
  3140. : determine compiler compiler
  3141. case "$yacc" in
  3142. '')
  3143.     dflt=yacc;;
  3144. *)
  3145.     dflt="$yacc";;
  3146. esac
  3147. echo " "
  3148. comp='yacc'
  3149. if $test -f "$byacc"; then
  3150.     dflt="$byacc"
  3151.     comp="byacc or $comp"
  3152. fi
  3153. if $test -f "$bison"; then
  3154.     comp="$comp or bison -y"
  3155. fi
  3156. rp="Which compiler compiler ($comp) shall I use?"
  3157. . ./myread
  3158. yacc="$ans"
  3159. case "$yacc" in
  3160. *bis*)
  3161.     case "$yacc" in
  3162.     *-y*) ;;
  3163.     *)
  3164.         yacc="$yacc -y"
  3165.         echo "(Adding -y option to bison to get yacc-compatible behaviour.)"
  3166.         ;;
  3167.     esac
  3168.     ;;
  3169. esac
  3170.  
  3171. : see if we should include -ly
  3172. echo " "
  3173. case "$yacc" in
  3174. *byacc*)
  3175.     echo "You are using byacc, so I won't look for a yacc library." >&4
  3176.     libyacc=''
  3177.     ;;
  3178. *yacc)
  3179.     xxx=`./loc liby.a x $libpth`
  3180.     case "$xxx" in
  3181.     x)
  3182.         echo "No yacc library found." >&4
  3183.         libyacc=''
  3184.         ;;
  3185.     *)
  3186.         echo "yacc library found in $xxx." >&4
  3187.         libyacc="$xxx"
  3188.         ;;
  3189.     esac
  3190.     ;;
  3191. *bison*)
  3192.     echo "You are using bison, so I won't look for a yacc library." >&4
  3193.     libyacc=''
  3194.     ;;
  3195. *)
  3196. echo "You don't seem to have yacc, so I won't look for the yacc library." >&4
  3197.     libyacc=''
  3198.     ;;
  3199. esac
  3200.  
  3201. : determine where manual pages go
  3202. $cat <<EOM
  3203.  
  3204. $package has manual pages available in source form.
  3205. EOM
  3206. case "$_nroff" in
  3207. nroff)
  3208.     echo "However, you don't have nroff, so they're probably useless to you."
  3209.     case "$mansrc" in
  3210.     '') mansrc="none";;
  3211.     esac;;
  3212. esac
  3213. echo "If you don't want the manual sources installed, answer 'none'."
  3214. case "$mansrc" in
  3215. '')
  3216.     lookpath="$prefix/man/man1 $prefix/man/u_man/man1 $prefix/man/l_man/man1"
  3217.     lookpath="$lookpath /usr/local/man/man1 /usr/local/man/man1 /usr/man/manl"
  3218.     lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
  3219.     lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  3220.     lookpath="$lookpath /usr/man/man.L"
  3221.     mansrc=`./loc . $prefix/man/man1 $lookpath`
  3222.     if $test -d "$mansrc"; then
  3223.         dflt="$mansrc"
  3224.     else
  3225.         dflt="$sysman"
  3226.     fi
  3227.     ;;
  3228. *)  dflt="$mansrc"
  3229.     ;;
  3230. esac
  3231. echo " "
  3232. fn=dn~
  3233. rp='Where do the manual pages (source) go?'
  3234. . ./getfile
  3235. mansrc="$ans"
  3236. mansrcexp="$ansexp"
  3237. if $afs; then
  3238.     $cat <<EOM
  3239.  
  3240. Since you are running AFS, I need to distinguish the directory in which
  3241. manual pages reside from the directory in which they are installed (and from
  3242. which they are presumably copied to the former directory by occult means).
  3243.  
  3244. EOM
  3245.     case "$installmansrc" in
  3246.     '') dflt=`echo $mansrcexp | sed 's#^/afs/#/afs/.#'`;;
  3247.     *) dflt="$installmansrc";;
  3248.     esac
  3249.     fn=de~
  3250.     rp='Where will man pages be installed?'
  3251.     . ./getfile
  3252.     installmansrc="$ans"
  3253. else
  3254.     installmansrc="$mansrcexp"
  3255. fi
  3256.  
  3257.  
  3258. case "$mansrc" in
  3259. '') manext='0';;
  3260. *l) manext=l;;
  3261. *n) manext=n;;
  3262. *o) manext=l;;
  3263. *p) manext=n;;
  3264. *C) manext=C;;
  3265. *L) manext=L;;
  3266. *L1) manext=L1;;
  3267. *) manext=1;;
  3268. esac
  3269.  
  3270. : find out how to generate dependencies
  3271. echo " "
  3272. echo "Checking how to generate makefile dependencies on your machine..." >&4
  3273. toplev=`cd ..;pwd`
  3274. $cat >dep.c <<'EOCP'
  3275. #include "dep.h"
  3276. EOCP
  3277. $cat >dep.h <<'EOCP'
  3278.  
  3279. EOCP
  3280. takeflags='flags=""
  3281. case "$@" in
  3282. *--*)
  3283.     for arg
  3284.     do
  3285.         shift
  3286.         case "$arg" in
  3287.         --) break;;
  3288.         *) flags="$flags $arg";;
  3289.         esac
  3290.     done;;
  3291. esac'
  3292. case "$mkdep" in
  3293. '')
  3294.     ;;
  3295. *)
  3296.     if test -x "$mkdep" &&
  3297.         $mkdep dep.c >dep.out 2>/dev/null &&
  3298.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  3299.     then
  3300.         echo "$mkdep works."
  3301.     else
  3302.         mkdep=
  3303.     fi
  3304. esac
  3305.  
  3306. case "$mkdep" in
  3307. '')
  3308.     $spitshell > ../mkdep <<EOM
  3309. $startsh
  3310. $takeflags
  3311. for srcfile
  3312. do
  3313.     $cpp -M -I. $cppflags \$flags \$srcfile 2>/dev/null
  3314. done
  3315. exit 0
  3316. EOM
  3317.     mkdep=$toplev/mkdep
  3318.     chmod +x $mkdep
  3319.     $eunicefix $mkdep
  3320.     if $mkdep dep.c >dep.out 2>/dev/null &&
  3321.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  3322.     then
  3323.         echo "Looks like we can use $cpp -M."
  3324.     else
  3325.         mkdep=
  3326.     fi
  3327.     ;;
  3328. esac
  3329.  
  3330. case "$mkdep" in
  3331. '')
  3332.     $spitshell > ../mkdep <<EOM
  3333. $startsh
  3334. $takeflags
  3335. for srcfile
  3336. do
  3337.     $cc -MM -I. $cppflags \$flags \$srcfile 2>/dev/null
  3338. done
  3339. exit 0
  3340. EOM
  3341.     mkdep=$toplev/mkdep
  3342.     chmod +x $mkdep
  3343.     $eunicefix $mkdep
  3344.     if $mkdep dep.c >dep.out 2>/dev/null &&
  3345.         $contains 'dep.o: dep.h' dep.out >/dev/null 2>&1
  3346.     then
  3347.         echo "Looks like we can use $cc -MM."
  3348.     else
  3349.         mkdep=
  3350.     fi
  3351.     ;;
  3352. esac
  3353.  
  3354. case "$mkdep" in
  3355. '')
  3356.     $spitshell >../mkdep <<EOS
  3357. $startsh
  3358. $takeflags
  3359. for srcfile
  3360. do
  3361.     case "\$srcfile" in
  3362.     *.c) c='.c';;
  3363.     *.y) c='.y';;
  3364.     *.l) c='.l';;
  3365.     esac
  3366.     filebase=\`basename \$srcfile \$c\`
  3367.     <\$srcfile $cpp $cppminus $cppflags -I. \$flags 2>/dev/null | \\
  3368.     $sed -e '/^# *[0-9]/!d' \\
  3369.         -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  3370.         -e 's|: \./|: |' \\
  3371.         -e 's|: *$|: '\$srcfile'|' | \\
  3372.     $grep -v '^#' | $sort | $uniq
  3373. done
  3374. exit 0
  3375. EOS
  3376.     mkdep=$toplev/mkdep
  3377.     chmod +x $mkdep
  3378.     $eunicefix $mkdep
  3379.     if $mkdep dep.c >dep.out 2>/dev/null &&
  3380.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  3381.     then
  3382.         echo "A shell script using $cpp does the trick."
  3383.     else
  3384.         echo "$cpp doesn't seem to be any use at all."
  3385.         $spitshell >../mkdep <<EOS
  3386. $startsh
  3387. $takeflags
  3388. files="\$@"
  3389. set X \$flags
  3390. shift
  3391. inc='.'
  3392. while test \$# -gt 0
  3393. do
  3394.     case "\$1" in
  3395.     -I) 
  3396.         shift
  3397.         inc="\$inc:\$1"
  3398.         ;;
  3399.     -I*)
  3400.         dir=\`echo \$1 | sed -e 's/^-I//'\`
  3401.         inc="\$inc:\$dir"
  3402.         ;;
  3403.     esac
  3404.     shift
  3405. done
  3406. set X \$files
  3407. shift
  3408. trap "$rm -f /tmp/mkdep\$\$; exit 1" 1 2 3 15
  3409. for srcfile
  3410. do
  3411.     case "\$srcfile" in
  3412.     *.c) c='.c';;
  3413.     *.y) c='.y';;
  3414.     *.l) c='.l';;
  3415.     esac
  3416.     filebase=\`basename \$srcfile \$c\`
  3417.     echo \$filebase.o: \$srcfile
  3418.     $grep '^#[  ]*include' \$srcfile /dev/null | \
  3419.     $sed -n -e 's/#[   ]*include[  ]*//' \\
  3420.         -e '/<\(.*\)>/ d' \\
  3421.         -e 's/:[^"]*"\([^"]*\)".*/: \1/' \\
  3422.         -e 's/\.c:/\.o:/p' > /tmp/mkdep\$\$
  3423.     IFS=': '
  3424.     while read file dep; do
  3425.         for dir in \$inc; do
  3426.             if $test -f "\$dir/\$dep"; then
  3427.                 dep="\$dir/\$dep"
  3428.                 break
  3429.             fi
  3430.         done
  3431.         echo "\$file: \$dep" | $sed -e 's,: \./,: ,'
  3432.     done </tmp/mkdep\$\$
  3433.     IFS=' '
  3434.     $rm -f /tmp/mkdep\$\$
  3435. done
  3436. exit 0
  3437. EOS
  3438.         mkdep=$toplev/mkdep
  3439.         chmod +x $mkdep
  3440.         $eunicefix $mkdep
  3441.         if $mkdep dep.c >dep.out 2>/dev/null &&
  3442.             $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  3443.         then
  3444.             cat << EOM
  3445.  
  3446. I can use a script with grep instead, but it will make some incorrect
  3447. dependencies, since it doesn't understand about conditional compilation.
  3448. Moreover, some dependencies may be missing, because scanning won't be
  3449. a recursive process.
  3450. If you have a program which generates makefile dependencies, you may want
  3451. to use it.  If not, you can use the script and edit the Makefile by hand
  3452. if you need to.
  3453. EOM
  3454.         else
  3455.             mkdep=
  3456.             cat << EOM
  3457.  
  3458. I can't seem to generate makefile dependencies at all!  Perhaps you have a
  3459. program that does?  If you don't, you might look at the mkdep script to
  3460. see if you can create one which works.
  3461. EOM
  3462.         fi
  3463.     fi
  3464. esac
  3465. dflt="$mkdep"
  3466. fn=f~/
  3467. rp="Name of program to make makefile dependencies?"
  3468. . ./getfile
  3469. mkdep="$ans"
  3470. $rm -f dep.c dep.h dep.o dep.out
  3471.  
  3472. : Cruising for prototypes
  3473. echo " "
  3474. echo "Checking out function prototypes..." >&4
  3475. $cat >prototype.c <<'EOCP'
  3476. main(int argc, char *argv[]) {
  3477.     exit(0);}
  3478. EOCP
  3479. if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
  3480.     echo "Your C compiler appears to support function prototypes."
  3481.     val="$define"
  3482. else
  3483.     echo "Your C compiler doesn't seem to understand function prototypes."
  3484.     val="$undef"
  3485. fi
  3486. set prototype
  3487. eval $setvar
  3488. $rm -f prototype*
  3489.  
  3490. : see if signal is declared as pointer to function returning int or void
  3491. echo " "
  3492. xxx=`./findhdr signal.h`
  3493. $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
  3494. if $contains 'int.*\*[     ]*signal' $$.tmp >/dev/null 2>&1 ; then
  3495.     echo "You have int (*signal())() instead of void." >&4
  3496.     val="$undef"
  3497. elif $contains 'void.*\*[     ]*signal' $$.tmp >/dev/null 2>&1 ; then
  3498.     echo "You have void (*signal())() instead of int." >&4
  3499.     val="$define"
  3500. elif $contains 'extern[     ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
  3501.     echo "You have int (*signal())() instead of void." >&4
  3502.     val="$undef"
  3503. else
  3504.     case "$d_voidsig" in
  3505.     '')
  3506.     echo "I can't determine whether signal handler returns void or int..." >&4
  3507.         dflt=void
  3508.         rp="What type does your signal handler return?"
  3509.         . ./myread
  3510.         case "$ans" in
  3511.         v*) val="$define";;
  3512.         *) val="$undef";;
  3513.         esac;;
  3514.     "$define")
  3515.         echo "As you already told me, signal handler returns void." >&4;;
  3516.     *)
  3517.         echo "As you already told me, signal handler returns int." >&4;;
  3518.     esac
  3519. fi
  3520. set d_voidsig
  3521. eval $setvar
  3522. case "$d_voidsig" in
  3523. "$define") signal_t="void";;
  3524. *) signal_t="int";;
  3525. esac
  3526. $rm -f $$.tmp
  3527.  
  3528. : see if time exists
  3529. echo " "
  3530. if set time val -f d_time; eval $csym; $val; then
  3531.     echo 'time() found.' >&4
  3532.     val="$define"
  3533.     case "$timetype" in
  3534.     '')
  3535.         if $contains 'time_t;' `./findhdr sys/types.h` >/dev/null 2>&1 ; then
  3536.             dflt='time_t';
  3537.         else
  3538.             dflt='long';
  3539.         fi
  3540.         ;;
  3541.     *)  dflt="$timetype"
  3542.         ;;
  3543.     esac
  3544.     echo " "
  3545.     rp="What type is returned by time() on this sytem?"
  3546.     . ./myread
  3547.     timetype="$ans"
  3548. else
  3549.     echo 'time() not found, hope that will do.' >&4
  3550.     val="$undef"
  3551.     timetype='int';
  3552. fi
  3553. set d_time
  3554. eval $setvar
  3555.  
  3556. : see if stdarg is available
  3557. echo " "
  3558. if $test `./findhdr stdarg.h`; then
  3559.     echo "<stdarg.h> found." >&4
  3560.     valstd="$define"
  3561. else
  3562.     echo "<stdarg.h> NOT found." >&4
  3563.     valstd="$undef"
  3564. fi
  3565.  
  3566. : see if varags is available
  3567. echo " "
  3568. if $test `./findhdr varargs.h`; then
  3569.     echo "<varargs.h> found." >&4
  3570. else
  3571.     echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
  3572. fi
  3573.  
  3574. : set up the varargs testing programs
  3575. $cat > varargs.c <<EOP
  3576. #ifdef I_STDARG
  3577. #include <stdarg.h>
  3578. #endif
  3579. #ifdef I_VARARGS
  3580. #include <varargs.h>
  3581. #endif
  3582.  
  3583. #ifdef I_STDARG
  3584. int f(char *p, ...)
  3585. #else
  3586. int f(va_alist)
  3587. va_dcl
  3588. #endif
  3589. {
  3590.     va_list ap;
  3591. #ifndef I_STDARG
  3592.     char *p;
  3593. #endif
  3594. #ifdef I_STDARG
  3595.     va_start(ap,p);
  3596. #else
  3597.     va_start(ap);
  3598.     p = va_arg(ap, char *);
  3599. #endif
  3600.     va_end(ap);
  3601. }
  3602. EOP
  3603. $cat > varargs <<EOP
  3604. if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
  3605.     echo "true"
  3606. else
  3607.     echo "false"
  3608. fi
  3609. $rm -f varargs.o
  3610. EOP
  3611. chmod +x varargs
  3612.  
  3613. : now check which varargs header should be included
  3614. echo " "
  3615. i_varhdr=''
  3616. case "$valstd" in
  3617. "$define")
  3618.     if `./varargs I_STDARG`; then
  3619.         val='stdarg.h'
  3620.     elif `./varargs I_VARARGS`; then
  3621.         val='varargs.h'
  3622.     fi
  3623.     ;;
  3624. *)
  3625.     if `./varargs I_VARARGS`; then
  3626.         val='varargs.h'
  3627.     fi
  3628.     ;;
  3629. esac
  3630. case "$val" in
  3631. '')
  3632. echo "I could not find the definition for va_dcl... You have problems..." >&4
  3633.     val="$undef"; set i_stdarg; eval $setvar
  3634.     val="$undef"; set i_varargs; eval $setvar
  3635.     ;;
  3636. *) 
  3637.     set i_varhdr
  3638.     eval $setvar
  3639.     case "$i_varhdr" in
  3640.     stdarg.h)
  3641.         val="$define"; set i_stdarg; eval $setvar
  3642.         val="$undef"; set i_varargs; eval $setvar
  3643.         ;;
  3644.     varargs.h)
  3645.         val="$undef"; set i_stdarg; eval $setvar
  3646.         val="$define"; set i_varargs; eval $setvar
  3647.         ;;
  3648.     esac
  3649.     echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
  3650. esac
  3651. $rm -f varargs*
  3652.  
  3653. : see if prototypes support variable argument declarations
  3654. echo " "
  3655. case "$prototype$i_stdarg" in
  3656. $define$define)
  3657.     echo "It appears we'll be able to prototype varargs functions." >&4
  3658.     val="$define"
  3659.     ;;
  3660. *)
  3661.     echo "Too bad... We won't be using prototyped varargs functions..." >&4
  3662.     val="$undef"
  3663.     ;;
  3664. esac
  3665. set vaproto
  3666. eval $setvar
  3667.  
  3668. $cat <<EOH
  3669.  
  3670. You may wish to compile with extra compiler warnings enabled.
  3671. Note that doing so enhances your chance of receiving your free set of steak
  3672. knives, particularly if you find any bugs and report them.
  3673. If you don't want extra warnings, answer "none".
  3674.   
  3675. EOH
  3676. case "$warnflags" in
  3677. '') case "$cc" in
  3678.     *gcc*)
  3679.         dflt="-Wall -Wno-comment"
  3680.         if $contains 'fprintf' `./findhdr stdio.h` >/dev/null 2>&1; then
  3681.             :
  3682.         else
  3683.             dflt="$dflt -Wno-implicit"
  3684.         fi
  3685.         ;;
  3686.     *) dflt="none";;
  3687.     esac
  3688.     ;;
  3689. ' ') dflt="none";;
  3690. *) dflt="$warnflags";;
  3691. esac
  3692.  
  3693. rp="Any $cc flags to enable warnings?"
  3694. . ./myread
  3695. case "$ans" in
  3696. none) warnflags=' ';;
  3697. *) warnflags="$ans";;
  3698. esac
  3699.  
  3700. : define an alternate in-header-list? function
  3701. inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
  3702. cont=true; xxf="echo \"<\$1> found.\" >&4";
  3703. case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
  3704. *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
  3705. esac;
  3706. case $# in 4) instead=instead;; *) instead="at last";; esac;
  3707. while $test "$cont"; do
  3708.     xxx=`./findhdr $1`
  3709.     var=$2; eval "was=\$$2";
  3710.     if $test "$xxx" && $test -r "$xxx";
  3711.     then eval $xxf;
  3712.         eval "case \"\$$var\" in $undef) . whoa; esac"; eval "$var=\$td";
  3713.         cont="";
  3714.     else eval $xxnf;
  3715.         eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu"; fi;
  3716.     set $yyy; shift; shift; yyy=$@;
  3717.     case $# in 0) cont="";;
  3718.     2) xxf="echo \"but I found <\$1> $instead.\" >&4";
  3719.         xxnf="echo \"and I did not find <\$1> either.\" >&4";;
  3720.     *) xxf="echo \"but I found <\$1\> instead.\" >&4";
  3721.         xxnf="echo \"there is no <\$1>, ...\" >&4";;
  3722.     esac;
  3723. done;
  3724. while $test "$yyy";
  3725. do set $yyy; var=$2; eval "was=\$$2";
  3726.     eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu";
  3727.     set $yyy; shift; shift; yyy=$@;
  3728. done'
  3729.  
  3730. : see if this is a sys/file.h system
  3731. val=''
  3732. set sys/file.h val
  3733. eval $inhdr
  3734.  
  3735. : do we need to #include <sys/file.h> ?
  3736. case "$val" in
  3737. "$define")
  3738.     echo " "
  3739.     if $h_sysfile; then
  3740.         val="$define"
  3741.         echo "We'll be including <sys/file.h>." >&4
  3742.     else
  3743.         val="$undef"
  3744.         echo "We won't be including <sys/file.h>." >&4
  3745.     fi
  3746.     ;;
  3747. *)
  3748.     h_sysfile=false
  3749.     ;;
  3750. esac
  3751. set i_sysfile
  3752. eval $setvar
  3753.  
  3754. : see if fcntl.h is there
  3755. val=''
  3756. set fcntl.h val
  3757. eval $inhdr
  3758.  
  3759. : see if we can include fcntl.h
  3760. case "$val" in
  3761. "$define")
  3762.     echo " "
  3763.     if $h_fcntl; then
  3764.         val="$define"
  3765.         echo "We'll be including <fcntl.h>." >&4
  3766.     else
  3767.         val="$undef"
  3768.         if $h_sysfile; then
  3769.     echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
  3770.         else
  3771.             echo "We won't be including <fcntl.h>." >&4
  3772.         fi
  3773.     fi
  3774.     ;;
  3775. *)
  3776.     h_fcntl=false
  3777.     val="$undef"
  3778.     ;;
  3779. esac
  3780. set i_fcntl
  3781. eval $setvar
  3782.  
  3783. : see if stddef is available
  3784. set stddef.h i_stddef
  3785. eval $inhdr
  3786.  
  3787. : see if stdlib is available
  3788. set stdlib.h i_stdlib
  3789. eval $inhdr
  3790.  
  3791. : see if we should include time.h, sys/time.h, or both
  3792. echo " "
  3793. echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
  3794. $echo $n "I'm now running the test program...$c"
  3795. $cat >try.c <<'EOCP'
  3796. #include <sys/types.h>
  3797. #ifdef I_TIME
  3798. #include <time.h>
  3799. #endif
  3800. #ifdef I_SYSTIME
  3801. #ifdef SYSTIMEKERNEL
  3802. #define KERNEL
  3803. #endif
  3804. #include <sys/time.h>
  3805. #endif
  3806. #ifdef I_SYSSELECT
  3807. #include <sys/select.h>
  3808. #endif
  3809. main()
  3810. {
  3811.     struct tm foo;
  3812. #ifdef S_TIMEVAL
  3813.     struct timeval bar;
  3814. #endif
  3815. #ifdef S_TIMEZONE
  3816.     struct timezone tzp;
  3817. #endif
  3818.     if (foo.tm_sec == foo.tm_sec)
  3819.         exit(0);
  3820. #ifdef S_TIMEVAL
  3821.     if (bar.tv_sec == bar.tv_sec)
  3822.         exit(0);
  3823. #endif
  3824.     exit(1);
  3825. }
  3826. EOCP
  3827. flags=''
  3828. s_timezone=''
  3829. sysselect=''
  3830. for s_timeval in '-DS_TIMEVAL' ''; do
  3831. for i_systimek in '' '-DSYSTIMEKERNEL'; do
  3832. for i_time in '' '-DI_TIME'; do
  3833. for i_systime in '-DI_SYSTIME' ''; do
  3834.     case "$flags" in
  3835.     '') $echo $n ".$c"
  3836.         if $cc $ccflags \
  3837.         $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone \
  3838.         try.c -o try >/dev/null 2>&1 ; then
  3839.             set X $i_time $i_systime $i_systimek $sysselect $s_timeval
  3840.             shift
  3841.             flags="$*"
  3842.             echo " "
  3843.             $echo $n "Succeeded with $flags$c"
  3844.         fi
  3845.         ;;
  3846.     esac
  3847. done
  3848. done
  3849. done
  3850. done
  3851. timeincl=''
  3852. echo " "
  3853. case "$flags" in
  3854. *SYSTIMEKERNEL*) i_systimek="$define"
  3855.     timeincl=`./findhdr sys/time.h`
  3856.     echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
  3857. *) i_systimek="$undef";;
  3858. esac
  3859. case "$flags" in
  3860. *I_TIME*) i_time="$define"
  3861.     timeincl=`./findhdr time.h`" $timeincl"
  3862.     echo "We'll include <time.h>." >&4;;
  3863. *) i_time="$undef";;
  3864. esac
  3865. case "$flags" in
  3866. *I_SYSTIME*) i_systime="$define"
  3867.     timeincl=`./findhdr sys/time.h`" $timeincl"
  3868.     echo "We'll include <sys/time.h>." >&4;;
  3869. *) i_systime="$undef";;
  3870. esac
  3871. $rm -f try.c try
  3872.  
  3873. : see if sys/types.h has to be included
  3874. set sys/types.h i_systypes
  3875. eval $inhdr
  3876.  
  3877. : see if this is a unistd.h system
  3878. set unistd.h i_unistd
  3879. eval $inhdr
  3880.  
  3881. : determine the name of a reasonable mailer
  3882. case "$mailer" in
  3883. '')
  3884.     if $test -f "$_sendmail"; then
  3885.         dflt="$_sendmail"
  3886.     elif $test -f "$_smail"; then
  3887.         dflt="$_smail"
  3888.     elif $test -f "$_rmail"; then
  3889.         dflt="$_rmail"
  3890.     elif $test -f /bin/mail; then
  3891.         dflt=/bin/mail
  3892.     else
  3893.         dflt=$mail
  3894.     fi
  3895.     ;;
  3896. *)  dflt="$mailer";;
  3897. esac
  3898. $cat <<EOM
  3899.  
  3900. I need the full pathname of the program used to deliver mail on your system.
  3901. A typical answer would be /usr/lib/sendmail or /bin/rmail, but you may choose
  3902. any other program, as long as it can be fed from standard input and will
  3903. honour any user-supplied headers.
  3904.  
  3905. EOM
  3906. fn=f
  3907. rp='Mail transport agent to be used?'
  3908. . ./getfile
  3909. mailer="$ans"
  3910.  
  3911. : set the base revision
  3912. baserev=2.0
  3913.  
  3914. : get the patchlevel
  3915. echo " "
  3916. echo "Getting the current patchlevel..." >&4
  3917. if $test -r ../patchlevel.h;then
  3918.     patchlevel=`awk '/PATCHLEVEL/ {print $3}' < ../patchlevel.h`
  3919. else
  3920.     patchlevel=0
  3921. fi
  3922. echo "(You have $package $baserev PL$patchlevel.)"
  3923.  
  3924. : notify author that his package is used
  3925. if $test -f ../.config/mailauthor &&
  3926.     cmp ../patchlevel.h ../.config/mailauthor >/dev/null 2>&1
  3927. then
  3928.     status="say that you're using $package";
  3929.     case "$mailpatches" in
  3930.     true) status='have patches mailed to you as they are issued';;
  3931.     esac
  3932.     case "$notifypatches" in
  3933.     true) status='be notified when new patches are issued';;
  3934.     esac
  3935.     $cat <<EOM
  3936.  
  3937. You have already sent the author of $package (greyham@research.canon.oz.au) mail to
  3938. $status. If you wish, you may modify
  3939. your previous request by sending a new mail with different options.
  3940.  
  3941. EOM
  3942.     rp='Should I send a status update to greyham@research.canon.oz.au?'
  3943.     dflt=n
  3944. else
  3945.     $cat <<EOM
  3946.  
  3947. If you are able to send mail to the Internet, the author of $package would
  3948. really appreciate you letting me send off a quick note, just to say that you've
  3949. tried it. The author is more likely to spend time maintaining $package if it's
  3950. known that many people are using it, and you can even ask to get sent new
  3951. patches automagically this way if you wish. To protect your privacy, all I'll
  3952. say in the mail is the version of $package that you're using.
  3953.  
  3954. EOM
  3955.     rp='Should I send mail to greyham@research.canon.oz.au?'
  3956.     dflt=y
  3957.     $test -f ../.config/nomail && dflt=n
  3958. fi
  3959. . ./myread
  3960. case "$ans" in
  3961. [yY]*)
  3962.     echo " "
  3963.     echo "Great!. You cooperation is really appreciated."
  3964.     $cat <<EOM
  3965.  
  3966. Some braindead sites do not set a proper return address in the From: header of
  3967. their outgoing mail, making it impossible to reply to mail they generate.
  3968. If your site is broken in this way, write to your system administrator and get
  3969. it fixed!!! In the mean time, you can manually specify the Internet e-mail
  3970. address by which the author can get back to you, should there be a need to do
  3971. so. If manually specified, it should be something like "user@domain.top".
  3972. If your mail system generates addresses correctly, specify "none".
  3973.  
  3974. EOM
  3975.     case "$usermail" in
  3976.     '-'|'') dflt=none;;
  3977.     *) dflt="$usermail";;
  3978.     esac
  3979.     rp='Manually specify a return address to use:'
  3980.     . ./myread
  3981.     case "$ans" in
  3982.     none|*@*.*)
  3983.         case "$ans" in
  3984.         none) usermail='-';;
  3985.         *) usermail="$ans";;
  3986.         esac
  3987.         ;;
  3988.     *)
  3989.         echo "(Address does not look like an Internet one -- ignoring it.)"
  3990.         usermail='-'
  3991.         mailpatches=false
  3992.         notifypatches=false
  3993.         ;;
  3994.     esac
  3995.     echo " "
  3996.     opt=''
  3997.     rp='Would you like to have new patches automatically mailed to you?'
  3998.     case "$mailpatches" in
  3999.     true) dflt=y;;
  4000.     *) dflt=n;;
  4001.     esac
  4002.     . ./myread
  4003.     case "$ans" in
  4004.     [yY]*) opt=' mailpatches'; mailpatches=true;;
  4005.     *)
  4006.         mailpatches=false
  4007.         echo " "
  4008.         rp='Ok, would you like to simply be notified of new patches?'
  4009.         case "$notifypatches" in
  4010.         false) dflt=n;;
  4011.         *) dflt=y;;
  4012.         esac
  4013.         . ./myread
  4014.         echo " "
  4015.         case "$ans" in
  4016.         [yY]*) opt=' notifypatches'; notifypatches=true;;
  4017.         *)
  4018.             echo "Fine, I'll simply say that you've tried it then."
  4019.             notifypatches=false
  4020.             ;;
  4021.         esac
  4022.         ;;
  4023.     esac
  4024.     echo "Sending mail to greyham@research.canon.oz.au..." >&4
  4025.     atsh='@SH'
  4026.     $mailer greyham@research.canon.oz.au <<EOM >/dev/null 2>&1
  4027. Subject: Command
  4028. Precedence: junk
  4029. To: greyham@research.canon.oz.au
  4030.  
  4031. $atsh package $usermail $package $baserev $patchlevel$opt
  4032. EOM
  4033.     $rm -f ../.config/mailauthor ../.config/nomail
  4034.     cp ../patchlevel.h ../.config/mailauthor
  4035.     ;;
  4036. *)
  4037.     case "$dflt" in
  4038.     "y")
  4039.         echo "Oh well, maybe next time."
  4040.         cp /dev/null ../.config/nomail
  4041.         ;;
  4042.     esac
  4043.     ;;
  4044. esac
  4045.  
  4046. : see if we have to deal with yellow pages, now NIS.
  4047. if $test -d /usr/etc/yp || $test -d /etc/yp; then
  4048.     if $test -f /usr/etc/nibindd; then
  4049.         echo " "
  4050.         echo "I'm fairly confident you're on a NeXT."
  4051.         echo " "
  4052.         rp='Do you get the passwd file via NetInfo?'
  4053.         dflt=y
  4054.         case "$passcat" in
  4055.         nidump*) ;;
  4056.         '') ;;
  4057.         *) dflt=n;;
  4058.         esac
  4059.         . ./myread
  4060.         case "$ans" in
  4061.         y*) passcat='nidump passwd .'
  4062.             ;;
  4063.         *)    echo "You told me, so don't blame me."
  4064.             passcat='cat /etc/passwd'
  4065.             ;;
  4066.         esac
  4067.         echo " "
  4068.         rp='Do you get the hosts file via NetInfo?'
  4069.         dflt=y
  4070.         case "$hostcat" in
  4071.         nidump*) ;;
  4072.         '') ;;
  4073.         *) dflt=n;;
  4074.         esac
  4075.         . ./myread
  4076.         case "$ans" in
  4077.         y*) hostcat='nidump hosts .';;
  4078.         *) hostcat='cat /etc/hosts';;
  4079.         esac
  4080.     fi
  4081.     case "$passcat" in
  4082.     nidump*) ;;
  4083.     *)
  4084.         case "$passcat" in
  4085.         *ypcat*) dflt=y;;
  4086.         '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
  4087.                 dflt=y
  4088.             else
  4089.                 dflt=n
  4090.             fi;;
  4091.         *) dflt=n;;
  4092.         esac
  4093.         echo " "
  4094.         rp='Are you getting the passwd file via yellow pages?'
  4095.         . ./myread
  4096.         case "$ans" in
  4097.         y*) passcat='ypcat passwd'
  4098.             ;;
  4099.         *)    passcat='cat /etc/passwd'
  4100.             ;;
  4101.         esac
  4102.         ;;
  4103.     esac
  4104.     case "$hostcat" in
  4105.     nidump*) ;;
  4106.     *)
  4107.         case "$hostcat" in
  4108.         *ypcat*) dflt=y;;
  4109.         '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
  4110.                 dflt=y
  4111.             else
  4112.                 dflt=n
  4113.             fi;;
  4114.         *) dflt=n;;
  4115.         esac
  4116.         echo " "
  4117.         rp='Are you getting the hosts file via yellow pages?'
  4118.         . ./myread
  4119.         case "$ans" in
  4120.         y*) hostcat='ypcat hosts';;
  4121.         *) hostcat='cat /etc/hosts';;
  4122.         esac
  4123.         ;;
  4124.     esac
  4125. fi
  4126.  
  4127. : find out how to find out full name
  4128. case "$d_berknames" in
  4129. "$define")
  4130.     dflt=y;;
  4131. "$undef")
  4132.     dflt=n;;
  4133. *)
  4134.     if bsd; then
  4135.         dflt=y
  4136.     elif xenix; then
  4137.         dflt=y
  4138.     else
  4139.         dflt=n
  4140.     fi
  4141.     ;;
  4142. esac
  4143. $cat <<'EOM'
  4144.  
  4145. Does your /etc/passwd file keep full names in Berkeley/V7 format (name first
  4146. thing after ':' in GCOS field)?  In that case, a typical entry in the password
  4147. file looks like this:
  4148.  
  4149.     guest:**paswword**:10:100:Mister Guest User:/usr/users:/bin/sh
  4150.                               ^^^^^^^^^^^^^^^^^
  4151. EOM
  4152. rp="Berkeley/V7 format for full name in /etc/passwd?"
  4153. . ./myread
  4154. case "$ans" in
  4155. y*) d_passnames="$define"
  4156.     d_berknames="$define"
  4157.     d_usgnames="$undef"
  4158.     nametype=bsd
  4159.     ;;
  4160. *)
  4161.     case "$d_usgnames" in
  4162.     "$define") dflt=y;;
  4163.     "$undef") dflt=n;;
  4164.     *)
  4165.         if usg; then
  4166.             dflt=y
  4167.         else
  4168.             dflt=n
  4169.         fi
  4170.         ;;
  4171.     esac
  4172. $cat <<'EOM'
  4173.  
  4174. Does your passwd file keep full names in USG format (name sandwiched between a
  4175. '-' and a '(')?  In that case, a typical entry in the password file looks like
  4176. this:
  4177.  
  4178.     guest:**paswword**:10:100:000-Mister Guest User(000):/usr/users:/bin/sh
  4179.                                   ^^^^^^^^^^^^^^^^^
  4180. EOM
  4181.     rp="USG format for full name in /etc/passwd?"
  4182.     . ./myread
  4183.     case "$ans" in
  4184.     n*) echo "Full name will be taken from ~/.fullname"
  4185.         d_passnames="$undef"
  4186.         d_berknames="$undef"
  4187.         d_usgnames="$undef"
  4188.         nametype=other
  4189.         ;;
  4190.     *)
  4191.         d_passnames="$define"
  4192.         d_berknames="$undef"
  4193.         d_usgnames="$define"
  4194.         nametype=usg
  4195.         ;;
  4196.     esac;;
  4197. esac
  4198.  
  4199. : figure out their full name
  4200. case "$NAME" in
  4201. '') case "$nametype" in
  4202.     other)
  4203.         fn=`./filexp ~/.fullname`
  4204.         xxx=usg
  4205.         $test -f $fn && xxx=other
  4206.         ;;
  4207.     *)
  4208.         xxx="$nametype"
  4209.         ;;
  4210.     esac
  4211.  
  4212.     case "$xxx" in
  4213.     bsd)
  4214.         cf_name=`$passcat | grep "^$cf_by:" | \
  4215.             sed -e 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1/' \
  4216.             -e 's/,.*//'`
  4217.         ;;
  4218.     usg)
  4219.         cf_name=`$passcat | grep "^$cf_by:" | \
  4220.             sed -e 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1/' \
  4221.             -e 's/[^-]*-\(.*\)(.*)/\1/'`
  4222.         ;;
  4223.     *)
  4224.         cf_name=`$cat $fn`
  4225.         ;;
  4226.     esac
  4227.     ;;
  4228. *)
  4229.     cf_name="$NAME"
  4230.     ;;
  4231. esac
  4232. echo " "
  4233. echo "Pleased to meet you, $cf_name."
  4234.  
  4235. : now get the host name
  4236. echo " "
  4237. echo "Figuring out host name..." >&4
  4238. case "$myhostname" in
  4239. '') cont=true
  4240.     echo 'Maybe "hostname" will work...'
  4241.     if tans=`sh -c hostname 2>&1` ; then
  4242.         myhostname=$tans
  4243.         phostname=hostname
  4244.         cont=''
  4245.     fi
  4246.     ;;
  4247. *) cont='';;
  4248. esac
  4249. if $test "$cont"; then
  4250.     if xenix; then
  4251.         echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
  4252.         if tans=`cat /etc/systemid 2>&1` ; then
  4253.             myhostname=$tans
  4254.             phostname='cat /etc/systemid'
  4255.             echo "Whadyaknow.  Xenix always was a bit strange..."
  4256.             cont=''
  4257.         fi
  4258.     elif $test -r /etc/systemid; then
  4259.         echo "(What is a non-Xenix system doing with /etc/systemid?)"
  4260.     fi
  4261. fi
  4262. if $test "$cont"; then
  4263.     echo 'No, maybe "uuname -l" will work...'
  4264.     if tans=`sh -c 'uuname -l' 2>&1` ; then
  4265.         myhostname=$tans
  4266.         phostname='uuname -l'
  4267.     else
  4268.         echo 'Strange.  Maybe "uname -n" will work...'
  4269.         if tans=`sh -c 'uname -n' 2>&1` ; then
  4270.             myhostname=$tans
  4271.             phostname='uname -n'
  4272.         else
  4273.             echo 'Oh well, maybe I can mine it out of whoami.h...'
  4274.             if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
  4275.                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
  4276.                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
  4277.             else
  4278.                 case "$myhostname" in
  4279.                 '') echo "Does this machine have an identity crisis or something?"
  4280.                     phostname='';;
  4281.                 *)
  4282.                     echo "Well, you said $myhostname before..."
  4283.                     phostname='echo $myhostname';;
  4284.                 esac
  4285.             fi
  4286.         fi
  4287.     fi
  4288. fi
  4289. : you do not want to know about this
  4290. set $myhostname
  4291. myhostname=$1
  4292.  
  4293. : translate upper to lower if necessary
  4294. case "$myhostname" in
  4295. *[A-Z]*)
  4296.     echo "(Normalizing case in your host name)"
  4297.     myhostname=`echo $myhostname | tr '[A-Z]' '[a-z]'`
  4298.     ;;
  4299. esac
  4300.  
  4301. : verify guess
  4302. if $test "$myhostname" ; then
  4303.     dflt=y
  4304.     rp='Your host name appears to be "'$myhostname'".'" Right?"
  4305.     . ./myread
  4306.     case "$ans" in
  4307.     y*) ;;
  4308.     *) myhostname='';;
  4309.     esac
  4310. fi
  4311.  
  4312. : bad guess or no guess
  4313. while $test "X$myhostname" = X ; do
  4314.     dflt=''
  4315.     rp="Please type the (one word) name of your host:"
  4316.     . ./myread
  4317.     myhostname="$ans"
  4318. done
  4319.  
  4320. case "$myhostname" in
  4321. *.*)
  4322.     dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
  4323.     myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
  4324.     echo "(Trimming domain name from host name--host name is now $myhostname)"
  4325.     ;;
  4326. *) case "$mydomain" in
  4327.     '')
  4328.         $hostcat >hosts
  4329.         dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
  4330.             hosts | $sort | $uniq | \
  4331.             $sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
  4332.         case "$dflt" in
  4333.         .) echo "(You do not have fully-qualified names in /etc/hosts)"
  4334.             tans=`./loc resolv.conf X /etc /usr/etc`
  4335.             if $test -f "$tans"; then
  4336.                 echo "(Attempting domain name extraction from $tans)"
  4337.                 dflt=.`egrep '^domain' $tans | $sed 's/domain[     ]*\(.*\)/\1/' \
  4338.                     | tr '[A-Z]' '[a-z]' 2>/dev/null`
  4339.             fi
  4340.             ;;
  4341.         esac
  4342.         case "$dflt" in
  4343.         .) echo "(No help from resolv.conf either -- attempting clever guess)"
  4344.             dflt=.`sh -c domainname 2>/dev/null`
  4345.             case "$dflt" in
  4346.             '') dflt='.';;
  4347.             .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
  4348.             esac
  4349.             ;;
  4350.         esac
  4351.         case "$dflt" in
  4352.         .) echo "(Lost all hope -- silly guess then)"
  4353.             dflt='.uucp'
  4354.             ;;
  4355.         esac
  4356.         $rm -f hosts
  4357.         ;;
  4358.     *) dflt="$mydomain";;
  4359.     esac;;
  4360. esac
  4361. echo " "
  4362. rp="What is your domain name?"
  4363. . ./myread
  4364. tans="$ans"
  4365. case "$ans" in
  4366. '') ;;
  4367. .*) ;;
  4368. *) tans=".$tans";;
  4369. esac
  4370. mydomain="$tans"
  4371.  
  4372. : translate upper to lower if necessary
  4373. case "$mydomain" in
  4374. *[A-Z]*)
  4375.     echo "(Normalizing case in your domain name)"
  4376.     mydomain=`echo $mydomain | tr '[A-Z]' '[a-z]'`
  4377.     ;;
  4378. esac
  4379.  
  4380. : a little sanity check here
  4381. case "$phostname" in
  4382. '') ;;
  4383. *)
  4384.     case `$phostname | tr '[A-Z]' '[a-z]'` in
  4385.     $myhostname$mydomain|$myhostname) ;;
  4386.     *)
  4387.         case "$phostname" in
  4388.         sed*)
  4389.             echo "(That doesn't agree with your whoami.h file, by the way.)"
  4390.             ;;
  4391.         *)
  4392.             echo "(That doesn't agree with your $phostname command, by the way.)"
  4393.             ;;
  4394.         esac
  4395.     ;;
  4396.     esac
  4397.     ;;
  4398. esac
  4399.  
  4400. $cat <<EOM
  4401.  
  4402. I need to get your e-mail address in Internet format if possible, i.e.
  4403. something like user@host.domain. Please answer accurately since I have
  4404. no easy means to double check it. The default value provided below
  4405. is most probably close to the reality but may not be valid from outside
  4406. your organization...
  4407.  
  4408. EOM
  4409. cont=x
  4410. while test "$cont"; do
  4411.     case "$cf_email" in
  4412.     '') dflt="$cf_by@$myhostname$mydomain";;
  4413.     *) dflt="$cf_email";;
  4414.     esac
  4415.     rp='What is your e-mail address?'
  4416.     . ./myread
  4417.     cf_email="$ans"
  4418.     case "$cf_email" in
  4419.     *@*.*) cont='' ;;
  4420.     *)
  4421.         rp='Address does not look like an Internet one.  Use it anyway?'
  4422.         case "$fastread" in
  4423.         yes) dflt=y ;;
  4424.         *) dflt=n ;;
  4425.         esac
  4426.         . ./myread
  4427.         case "$ans" in
  4428.         y*) cont='' ;;
  4429.         *) echo " " ;;
  4430.         esac
  4431.         ;;
  4432.     esac
  4433. done
  4434.  
  4435. : offer to join the mailing list
  4436. list_request='listserv@research.canon.oz.au'
  4437. list_sub="SUBSCRIBE c2man $cf_name"
  4438. list_unsub="UNSUBSCRIBE c2man"
  4439. list_name="c2man"
  4440. $cat <<EOM
  4441.  
  4442. There is a mailing list for discussion about $package and related issues.
  4443. This is the preferred place to ask questions about the program and discuss
  4444. modifications and additions with the author and other users.  If you are able
  4445. to send mail to the Internet, you are encouraged to subscribe.  You need only
  4446. ever subscribe once, and you can unsubscribe automatically at any time in the
  4447. future.  If you have already subscribed and you wish to unsubscribe now, you
  4448. may do so by answering "unsubscribe".  Answer "subscribe" to subscribe to the
  4449. list.
  4450.  
  4451. EOM
  4452. rp="Subscribe to or unsubscribe from the $list_name mailing list?"
  4453. dflt=neither
  4454. . ./myread
  4455. case "$ans" in
  4456. [sS]*)    $cat <<EOM
  4457.  
  4458. You will be sent a message from the list server to let you know when your
  4459. subscription has been successful and telling you how to submit articles and
  4460. how to unsubscribe again when necessary. You may also unsubscribe by running
  4461. this script again and asking it to do so for you.
  4462.  
  4463. EOM
  4464.     echo "Sending mail to subscribe you to the $list_name list..." >&4
  4465.     $mailer $list_request <<EOM >/dev/null 2>&1
  4466. Precedence: junk
  4467. To: $list_request
  4468.  
  4469. $list_sub
  4470. EOM
  4471.     ;;
  4472. [uU]*)    echo "Sending mail to unsubscribe you from the $list_name list..." >&4
  4473.     $mailer $list_request <<EOM >/dev/null 2>&1
  4474. Precedence: junk
  4475. To: $list_request
  4476.  
  4477. $list_unsub
  4478. EOM
  4479.     ;;
  4480. esac
  4481.  
  4482. : end of configuration questions
  4483. echo " "
  4484. echo "End of configuration questions."
  4485. echo " "
  4486.  
  4487. : back to where it started
  4488. if test -d ../UU; then
  4489.     cd ..
  4490. fi
  4491.  
  4492. : configuration may be patched via a 'config.over' file
  4493. if $test -f config.over; then
  4494.     echo " "
  4495.     dflt=y
  4496.     rp='I see a config.over file.  Do you wish to load it?'
  4497.     . UU/myread
  4498.     case "$ans" in
  4499.     n*) echo "OK, I'll ignore it.";;
  4500.     *)    . ./config.over
  4501.         echo "Configuration override changes have been loaded."
  4502.         ;;
  4503.     esac
  4504. fi
  4505.  
  4506. : create config.sh file
  4507. echo " "
  4508. echo "Creating config.sh..." >&4
  4509. $spitshell <<EOT >config.sh
  4510. $startsh
  4511. #
  4512. # This file was produced by running the Configure script. It holds all the
  4513. # definitions figured out by Configure. Should you modify one of these values,
  4514. # do not forget to propagate your changes by running "Configure -der". You may
  4515. # instead choose to run each of the .SH files by yourself, or "Configure -S".
  4516. #
  4517.  
  4518. # Configuration time: $cf_time
  4519. # Configured by: $cf_by
  4520. # Target system: $myuname
  4521.  
  4522. d_bsd='$d_bsd'
  4523. d_eunice='$d_eunice'
  4524. d_xenix='$d_xenix'
  4525. eunicefix='$eunicefix'
  4526. Mcc='$Mcc'
  4527. awk='$awk'
  4528. bash='$bash'
  4529. bison='$bison'
  4530. byacc='$byacc'
  4531. cat='$cat'
  4532. chgrp='$chgrp'
  4533. chmod='$chmod'
  4534. chown='$chown'
  4535. compress='$compress'
  4536. cp='$cp'
  4537. cpio='$cpio'
  4538. cpp='$cpp'
  4539. csh='$csh'
  4540. date='$date'
  4541. echo='$echo'
  4542. egrep='$egrep'
  4543. emacs='$emacs'
  4544. expr='$expr'
  4545. find='$find'
  4546. flex='$flex'
  4547. gcc='$gcc'
  4548. grep='$grep'
  4549. inews='$inews'
  4550. ksh='$ksh'
  4551. less='$less'
  4552. line='$line'
  4553. lint='$lint'
  4554. ln='$ln'
  4555. lp='$lp'
  4556. lpr='$lpr'
  4557. ls='$ls'
  4558. mail='$mail'
  4559. mailx='$mailx'
  4560. make='$make'
  4561. mkdir='$mkdir'
  4562. more='$more'
  4563. mv='$mv'
  4564. nroff='$nroff'
  4565. perl='$perl'
  4566. pg='$pg'
  4567. pmake='$pmake'
  4568. pr='$pr'
  4569. rm='$rm'
  4570. rmail='$rmail'
  4571. sed='$sed'
  4572. sendmail='$sendmail'
  4573. sh='$sh'
  4574. shar='$shar'
  4575. sleep='$sleep'
  4576. smail='$smail'
  4577. sort='$sort'
  4578. submit='$submit'
  4579. tail='$tail'
  4580. tar='$tar'
  4581. tbl='$tbl'
  4582. test='$test'
  4583. touch='$touch'
  4584. tr='$tr'
  4585. troff='$troff'
  4586. uname='$uname'
  4587. uniq='$uniq'
  4588. uuname='$uuname'
  4589. vi='$vi'
  4590. zcat='$zcat'
  4591. mailpatches='$mailpatches'
  4592. notifypatches='$notifypatches'
  4593. usermail='$usermail'
  4594. hint='$hint'
  4595. myuname='$myuname'
  4596. Author='$Author'
  4597. Date='$Date'
  4598. Header='$Header'
  4599. Id='$Id'
  4600. Locker='$Locker'
  4601. Log='$Log'
  4602. RCSfile='$RCSfile'
  4603. Revision='$Revision'
  4604. Source='$Source'
  4605. State='$State'
  4606. afs='$afs'
  4607. baserev='$baserev'
  4608. bin='$bin'
  4609. binexp='$binexp'
  4610. installbin='$installbin'
  4611. cc='$cc'
  4612. gccversion='$gccversion'
  4613. ccflags='$ccflags'
  4614. cppflags='$cppflags'
  4615. ldflags='$ldflags'
  4616. lkflags='$lkflags'
  4617. optimize='$optimize'
  4618. cf_email='$cf_email'
  4619. cf_by='$cf_by'
  4620. cf_time='$cf_time'
  4621. contains='$contains'
  4622. cppfilecom='$cppfilecom'
  4623. cppstdinflags='$cppstdinflags'
  4624. d_cppcanstdin='$d_cppcanstdin'
  4625. d_cppignhdrs='$d_cppignhdrs'
  4626. cpplast='$cpplast'
  4627. cppminus='$cppminus'
  4628. cpprun='$cpprun'
  4629. cppstdin='$cppstdin'
  4630. d_access='$d_access'
  4631. d_const='$d_const'
  4632. d_flexfnam='$d_flexfnam'
  4633. d_link='$d_link'
  4634. d_open3='$d_open3'
  4635. d_portable='$d_portable'
  4636. d_index='$d_index'
  4637. d_strchr='$d_strchr'
  4638. d_strftime='$d_strftime'
  4639. d_strstr='$d_strstr'
  4640. d_symlink='$d_symlink'
  4641. d_time='$d_time'
  4642. timetype='$timetype'
  4643. d_voidsig='$d_voidsig'
  4644. signal_t='$signal_t'
  4645. d_volatile='$d_volatile'
  4646. h_fcntl='$h_fcntl'
  4647. h_sysfile='$h_sysfile'
  4648. i_fcntl='$i_fcntl'
  4649. i_stddef='$i_stddef'
  4650. i_stdlib='$i_stdlib'
  4651. i_string='$i_string'
  4652. strings='$strings'
  4653. i_sysfile='$i_sysfile'
  4654. i_systypes='$i_systypes'
  4655. i_systime='$i_systime'
  4656. i_systimek='$i_systimek'
  4657. i_time='$i_time'
  4658. timeincl='$timeincl'
  4659. i_unistd='$i_unistd'
  4660. i_stdarg='$i_stdarg'
  4661. i_varargs='$i_varargs'
  4662. i_varhdr='$i_varhdr'
  4663. lex='$lex'
  4664. lexflags='$lexflags'
  4665. libc='$libc'
  4666. liblex='$liblex'
  4667. glibpth='$glibpth'
  4668. libpth='$libpth'
  4669. plibpth='$plibpth'
  4670. xlibpth='$xlibpth'
  4671. libs='$libs'
  4672. libyacc='$libyacc'
  4673. mailer='$mailer'
  4674. installmansrc='$installmansrc'
  4675. manext='$manext'
  4676. mansrc='$mansrc'
  4677. mansrcexp='$mansrcexp'
  4678. mkdep='$mkdep'
  4679. mydomain='$mydomain'
  4680. myhostname='$myhostname'
  4681. phostname='$phostname'
  4682. c='$c'
  4683. n='$n'
  4684. d_berknames='$d_berknames'
  4685. d_passnames='$d_passnames'
  4686. d_usgnames='$d_usgnames'
  4687. nametype='$nametype'
  4688. groupcat='$groupcat'
  4689. hostcat='$hostcat'
  4690. passcat='$passcat'
  4691. package='$package'
  4692. spackage='$spackage'
  4693. patchlevel='$patchlevel'
  4694. prefix='$prefix'
  4695. installprivlib='$installprivlib'
  4696. privlib='$privlib'
  4697. privlibexp='$privlibexp'
  4698. prototype='$prototype'
  4699. so='$so'
  4700. sharpbang='$sharpbang'
  4701. shsharp='$shsharp'
  4702. spitshell='$spitshell'
  4703. startsh='$startsh'
  4704. sysman='$sysman'
  4705. nm_opt='$nm_opt'
  4706. runnm='$runnm'
  4707. usenm='$usenm'
  4708. incpath='$incpath'
  4709. mips='$mips'
  4710. mips_type='$mips_type'
  4711. usrinc='$usrinc'
  4712. vaproto='$vaproto'
  4713. defvoidused='$defvoidused'
  4714. voidflags='$voidflags'
  4715. warnflags='$warnflags'
  4716. yacc='$yacc'
  4717. yaccflags='$yaccflags'
  4718. EOT
  4719.  
  4720. : add special variables
  4721. $test -f patchlevel.h && \
  4722. awk '/^#define/ {printf "%s=%s\n",$2,$3}' patchlevel.h >>config.sh
  4723. echo "CONFIG=true" >>config.sh
  4724.  
  4725. : propagate old symbols
  4726. if $test -f UU/config.sh; then
  4727.     <UU/config.sh sort | uniq >UU/oldconfig.sh
  4728.     sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
  4729.     sort | uniq -u >UU/oldsyms
  4730.     set X `cat UU/oldsyms`
  4731.     shift
  4732.     case $# in
  4733.     0) ;;
  4734.     *)
  4735.         cat <<EOM
  4736. Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
  4737. EOM
  4738.         echo "# Variables propagated from previous config.sh file." >>config.sh
  4739.         for sym in `cat UU/oldsyms`; do
  4740.             echo "    Propagating $hint variable "'$'"$sym..."
  4741.             eval 'tmp="$'"${sym}"'"'
  4742.             echo "$tmp" | \
  4743.                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
  4744.         done
  4745.         ;;
  4746.     esac
  4747. fi
  4748.  
  4749. : Finish up by extracting the .SH files
  4750. case "$alldone" in
  4751. exit)
  4752.     $rm -rf UU
  4753.     echo "Done."
  4754.     exit 0
  4755.     ;;
  4756. cont)
  4757.     ;;
  4758. '')
  4759.     echo " "
  4760.     dflt=''
  4761.     nostick=true
  4762. echo "If you didn't make any mistakes, then just type a carriage return here."
  4763.     rp="If you need to edit config.sh, do it as a shell escape here:"
  4764.     . UU/myread
  4765.     nostick=''
  4766.     case "$ans" in
  4767.     '') ;;
  4768.     *) : in case they cannot read
  4769.         sh 1>&4 -c "$ans";;
  4770.     esac
  4771.     ;;
  4772. esac
  4773.  
  4774. : if this fails, just run all the .SH files by hand
  4775. . ./config.sh
  4776.  
  4777. echo " "
  4778. exec 1>&4
  4779. . ./UU/extract
  4780.  
  4781. if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
  4782.     dflt=y
  4783.     case "$silent" in
  4784.     true) ;;
  4785.     *)
  4786.         $cat <<EOM
  4787.  
  4788. Now you need to generate make dependencies by running "make depend".
  4789. You might prefer to run it in background: "make depend > makedepend.out &"
  4790. It can take a while, so you might not want to run it right now.
  4791.  
  4792. EOM
  4793.         ;;
  4794.     esac
  4795.     rp="Run make depend now?"
  4796.     . UU/myread
  4797.     case "$ans" in
  4798.     y*)
  4799.         make depend && echo "Now you must run a make."
  4800.         ;;
  4801.     *)
  4802.         echo "You must run 'make depend' then 'make'."
  4803.         ;;
  4804.     esac
  4805. elif test -f [Mm]akefile; then
  4806.     echo " "
  4807.     echo "Now you must run a make."
  4808. else
  4809.     echo "Done."
  4810. fi
  4811.  
  4812. $rm -f kit*isdone ark*isdone
  4813. $rm -rf UU
  4814.  
  4815. : End of Configure
  4816.  
  4817.